Repository navigation
fix(sema): declaration based type identity for structs, enums and generic instances - #3758
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
sha=a08b52a3f48d626a7027a9528b6b399e2a70bca7
🤖 Salam AI reviewVerdict: 🛠️ Changes needed before merging commit SummaryThis PR fixes type identity in semantic analysis by replacing name-based struct/enum/dyn equivalence with declaration-origin identity and by making generic instance keys include full argument identity. The core direction is correct and the added tests cover the reported name-collision and generic-argument-collision cases, but the qualified-name handling introduces a lookup bug for dotted package names in LLVM and a possible visibility gap in the new semantic fallback. What changedThis PR changes type identity so struct, enum, and Review
TestsThe new tests are well targeted: RisksThe main risk is incomplete migration from underscore-mangled qualified names to dotted
|
|
Checked with real programs against the main-built baseline.
|
type_equiv fell back to comparing mangled names, so a local struct a_Item unified with the imported a.Item (check passed, exec failed with a missing field, clang and LLVM failed differently). Generic instance keys used bare type names, so a.Meters and b.Meters collided.
Types now record the declaration they came from (file, offset, name) and type_equiv compares that; the name fallback is gone. Qualified type names use the pkg.Name form, with lookups for interfaces, LLVM and the interpreter updated to match, and generic instance keys include the full identity of every argument. A duplicate alias typedef in the C output for imported aliases is fixed too.
Tested with a main-built compiler: check, run, exec, js, llvm and native on the reported repros; 141 related error tests via check; 80 related feature runs on run and exec; check compiler/main.salam is clean and the compiler bootstraps through stage 2. New tests: tests/en/features/struct_pkg_name_identity and tests/en/errors/struct_pkg_name_identity.