You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trait default methods (any?, all?, ==) don't dispatch for opt-in stdlib types on BEAM #235
Discovered while fixing #233. Data.Set/Data.Stack/Data.Queue/Data.UnorderedSet all implement Enumerable/Foldable (whose any?/all?/etc. are trait DEFAULT methods derived from reduce), and Queue overloads ==. On BEAM, calling these trait-provided methods fails outright rather than falling back to the derived implementation.
Repro
using Data.Stack
main do
let s = Stack.from([1, 2, 3])
IO.printLine("${s.any? { |x| x > 2 }}")
end
Run with ./build/kex -R → Undefined method: any? for Data.Stack.
Also seen:
spec/stdlib/data_set.spec.kex: Foldable queries come for free → Undefined method: any? for Data.Set
spec/stdlib/data_stack.spec.kex: same, for Data.Stack
spec/stdlib/data_queue.spec.kex: Foldable queries come for free → Undefined method: any? for Data.Queue, and separately peek answers the front element → Undefined method: == for Option<Int> (comparing Queue.from([1,2,3]).peek to Just(1))
The tree-walk interpreter is unaffected — make spec-stdlib passes cleanly for all of these; only -c/-R fail.
Likely area
Trait default-method inheritance for a make Type, implement: Trait do ... end block is handled somewhere in src/ir/lower.cxx's trait-splicing pass (mentioned near lowerMakeGroup/inheritedDefaults — "a make Type, implement: T do ... end block inherits every default method ... of each T it doesn't override itself"). Given this is the first time an OPT-IN, SOURCE-LOADED module (rather than a prelude-tier type) implements Enumerable/Foldable purely via inherited defaults with no local override, this path may simply not have been exercised for that combination before.
Related: #229, #233 (the module-alias fix that exposed this), #234 (a second, separate lowering bug found in the same investigation).
Activity