fix: give error-set decls per-decl nominal identity (issue 0134)

A local 'error { ... }' set with the same name as an imported one collapsed
onto the import, losing its own tags, because registerErrorSetDecl deduped via
the flat findByName path while struct/enum/union use E6a per-decl identity.
Build the .error_set TypeInfo (new buildErrorSetInfo helper factored from
resolveInlineErrorSet) and intern via internNamedTypeDecl with shadowNominalId;
reserve a distinct shadow slot in scanDecls; consult per-decl type_decl_tids in
namedRefTid before findByName. The inline/anonymous findByName short-circuit is
preserved.

Regression: examples/1059-errors-same-name-error-set-own-wins.sx (moved from
issues/0134).
This commit is contained in:
agra
2026-06-21 09:11:06 +03:00
parent ad45ae07ef
commit 333f57026c
8 changed files with 81 additions and 4 deletions

View File

@@ -1745,6 +1745,7 @@ pub const Lowering = struct {
pub const reserveShadowStructSlot = lower_nominal.reserveShadowStructSlot;
pub const reserveShadowEnumSlot = lower_nominal.reserveShadowEnumSlot;
pub const reserveShadowUnionSlot = lower_nominal.reserveShadowUnionSlot;
pub const reserveShadowErrorSetSlot = lower_nominal.reserveShadowErrorSetSlot;
pub const topLevelTypeDecl = lower_nominal.topLevelTypeDecl;
pub const reserveShadowSlot = lower_nominal.reserveShadowSlot;
pub const internNamedTypeDecl = lower_nominal.internNamedTypeDecl;