Repository navigation
Conversation
added 2 commits
October 27, 2026 17:39
…tes (#750, #2758) A program declaring 'type Option = i32' broke std itself: every '?' in std failed with '? operator requires an Option...' inside <embedded-std>, and 'type Result = i32' ICE'd in f64.parse_text. Ordinary user types shadowed correctly; only the names the compiler's generic machinery depends on leaked. Root cause, exact lines (lldb on the installed compiler, then a traced stage1): Sema.try_unwrapped_type returns 0 for every std '?' because resolve_generic_enum_payload (SemaCheck.w) fetched the instance's template declaration from type_decl_nodes by bare name - the flat map where the user's alias, registered last, displaces std's enum decl (SemaDecl.w collect_type_decl). Not-an-enum made it return no payloads; the raw type_extra payload is the unsubstituted parameter slot 0. The same displacement in named_types fed MIR/TypeLayout/Codegen template fetches by base symbol (audit:resolution: field bases ty=14 (i32) in MIR vs ty=491 in Sema inside Regex.captures_match_op). Fix by identity, not by name, at the owners: the payload/thread-trait/pending-enum lookups resolve the template through the instance's recorded template (generic_inst_decl_node / type_decl_nodes_by_tid, the #1745 pattern struct_literal_decl_node already used); the flat registries no longer let a non-generic declaration displace a generic template entry (candidates still record every declaration, so source name resolution and user-side shadowing are unchanged); bare_generic_annotation and the MIR validator's uninstantiated-generic set judge the declaration the name/type actually denotes, not the flat map's answer. Scope: generic-vs-generic reuse of one name (a user's generic Option[T]) still resolves flat in places - that is #751 carrying identity through instantiation; it fails loudly, never silently. Evidence: behav_750_user_option_shadows_std, behav_750_user_option_struct, behav_750_user_result_shadows_std (all fail pre-fix, the last with the #2758 ICE); audit:resolution clean; neighboring shadowing/generic-enum fixtures pass.
) Battery fallout of the flat-map rule below it in this layer: the flat type_decl_nodes/named_types now keep std's generic Handle[T], and every reader that asked that map whether a name is generic answered for std's type instead of the user's same-named one. Observed exact lines: type_decl_type_param_count (SemaDecl.w) read the flat map, so std's blanket impl[T] Copy for Handle[T] applied to a user's Handle (spurious Copy/Drop conflict, E1201 overlaps); fn_node_is_generic_template and collect_fn_decl's generic-struct test split the symbol text into the same map, registering a user's Handle methods as generic templates; check_generic_method_call took the owner's type parameters from the flat map, so a facade Handle's set call tried to infer std Handle's T; struct_decl_needs_liveness_byte read std's fields and the name-keyed cache let the first Handle laid out answer for both (a pointer-field Handle grew the liveness byte). Each now judges the declaration the type itself denotes: type_tid_decl_tp_count / owner_decl_node_for_type by tid identity (type_decl_nodes_by_tid, generic_inst_decl_node), Self's own tid in collect_fn_decl, and a declaration-keyed liveness verdict that TypeLayout and both codegens read by tid/decl node. Regression: test/behavior/behav_750_user_handle_drop.w (failed before with the Copy conflict); behav_liveness_byte_sizeof, err_1930, spec_ss17_7 and the c_facade variadic fixtures pass again.
abi-hash-check: src/TypeLayout.w changed (liveness byte keyed by the laid-out type); the convention is unchanged, so no WITH_ABI_VERSION bump. Every .wo rebuilds once.
ehartford
marked this pull request as ready for review
October 28, 2026 00:35
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack created with GitHub Stacks CLI • Give Feedback 💬