fix(types): preserve package-local bare type identity#2626
Open
slepp wants to merge 2 commits into
Open
Conversation
…ntity (#2208) A bare type reference inside a non-root module (e.g. a `Holder { w: Wrap }` field whose `Wrap` is declared in the same module) resolved through the `is_local` arm to the BARE `type_defs` key. That key is last-write-wins across modules that declare the same bare name — `pre_register_type_decl` documents the qualified alias as the authority — so when a sibling module declares its own `Wrap`, the field silently bound to whichever module registered `Wrap` last. This is observable in a correctly-disambiguated program (contradicting the issue's "unobservable" note): two package-local modules each with a divergent `Wrap` + `Holder { w: Wrap }` mis-resolve one holder's field to the other module's layout, surfacing as `no field `a_field` on type `Wrap` — help: b_field`, and the winner flips with import order. Fix: in the `is_local` arm, bind to the current module's OWN qualified identity (`{short}.{name}`) when that key exists, mirroring the sibling `published_bare_type_qualified` branch that already qualifies to dodge the same bare-key collapse. `pre_register_type_decl` always seeds the qualified key alongside the bare one, so non-colliding locals and root-module refs (`current_module_short() == None`) resolve exactly as before. Load-bearing regression `same_bare_name_member_field_binds_to_own_module_identity` asserts each holder's `w` field carries its own module's `Wrap` identity; it fails on revert (both collapse to the last-writer). Full hew-types (1665 lib + integration) and hew-hir suites green; fmt + clippy(--tests) clean.
Carry full declaring-module paths through stdlib visibility metadata, preserve owner-qualified type definitions across bare-name collisions, and keep local handle and trait Self identities coherent after qualification. Add the nested private-local regression and exercise both #2208 import orders.
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.
Summary
Selfsubstitution coherent after local names become qualified.This takes over and completes @gertybotbot's work in #2619. Their original own-qualified binding and collision regression are preserved as an authored commit in this branch. Thanks to @gertybotbot for reporting #2208 and for the original fix.
Fixes #2208
Testing
hew check hew-types/tests/fixtures/net_parameter_surfaces_typecheck.hewmake hew-check-all(1,575 files; expected failure set matched)cargo test -p hew-typescargo test -p hew-hircargo check --workspace