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
== on an enum or Vec with a str payload compares representation bytes: Option[str] == Some("a") is false #2137
Expected true on every line. Option[i32] == Some(3), a tuple ("a", 1) == ("a", 1) and a struct with a str field all compare correctly.
Where:Codegen.compare_aggregate_eq (src/Codegen.w) decides what == means from the LLVM type: a struct is compared member by member, and an enum is {tag, [payload bytes]}, so its payload is compared as raw bytes — a str payload by its pointer, a Vec by pointer/len/cap. That is codegen reconstructing a meaning Sema owns (D65). derive(Eq) on an enum changes nothing.
Tool that stayed silent:examples/c-interop/test/database_test.w asserts rows.column_text(0).map(t => t.to_str_lossy()) == Some("a") and failed.errmsg().map(...) == Some("unable to open database file"); both fail on main, and no gate runs the example projects' own tests (with build :test in examples/c-interop: 2 of 7 fail). There is no behavior test of Option[str] equality.
Fix owed: Sema decides equality per With type (the Eq impl, or the derived variant-by-variant comparison for enums); codegen lowers that and never falls back to bytes for a type holding a str, Vec or other owned payload. examples-tests runs each example's tests.
Fixed in #2143 (main 6b0c99d, installed). == on an aggregate is rendered from its With type: Sema records the eq each part is compared by (specialized for a generic part), codegen emits a per-type walk. Option/Result/enum payloads, Vec, Box, tuples and arrays of them, structs holding them, views of aggregates, Vec.contains/in, and == on a generic type with its own eq all compare by value; an owning temporary used as an operand is dropped (it leaked). examples-tests now runs examples/c-interop and its 13 tests. Test: behav_2137_structural_equality; verified on macOS, Linux x86_64 (gate) and Windows x86_64.
Activity
#2137: Vec.contains and `in` compare by type; a comparison's owning t…
#2137: the hidden eq calls are calls to the effects analysis; example…
== compares a value by its With type, never by its bytes (#2137) (#2143)
ehartford commentedon Oct 5, 2026
Fixed in #2143 (main 6b0c99d, installed).
==on an aggregate is rendered from its With type: Sema records theeqeach part is compared by (specialized for a generic part), codegen emits a per-type walk. Option/Result/enum payloads, Vec, Box, tuples and arrays of them, structs holding them, views of aggregates,Vec.contains/in, and==on a generic type with its owneqall compare by value; an owning temporary used as an operand is dropped (it leaked).examples-testsnow runs examples/c-interop and its 13 tests. Test:behav_2137_structural_equality; verified on macOS, Linux x86_64 (gate) and Windows x86_64.emitc selfbuild (#2819)