Files
sx/issues/0134-error-set-no-per-decl-nominal-identity-same-name-collapse.sx
agra 45befed698 docs(issues): correct 0132 root cause; file 0133 and 0134
- 0132: rewrite to the verified root cause -- protocol method signature
  registration resolves type names via flat findByName and picks the wrong
  same-name author. Original payload-field hypothesis kept as superseded;
  repro switched to canonical `impl ... for` syntax. Still open (the
  protocol path is unchanged).
- 0133: assigning a struct literal to a union member panics ("unresolved
  type reached LLVM emission"); pre-existing, surfaced while testing.
- 0134: a same-name `error` set collapses into a namespaced import's set --
  error-set declarations lack per-decl nominal identity (E6a gap); this is
  what keeps the 0132-class error-ref resolution dormant.
2026-06-13 13:41:30 +03:00

40 lines
1.4 KiB
Plaintext

// issue 0134 — a same-name `error` set collapses into a namespaced import's
// set (error sets lack per-decl nominal identity).
//
// `EventErr` is declared locally as `error { Boom }`, but
// `#import "modules/std.sx"` also carries `event.EventErr` (an error set with
// tags Init/Register/Wait). Because error-set DECLARATIONS are not given
// per-decl nominal identity (unlike struct/enum/union under E6a) —
// `registerErrorSetDecl` registers via the flat `findByName`-dedup path — the
// local `EventErr` collapses into the imported one, losing its own `Boom` tag.
//
// So `raise error.Boom` / `r == error.Boom` are checked against the IMPORTED
// set, which has no `Boom`.
//
// EXPECT (today): build FAILS —
// error: error tag 'error.Boom' is not in error set 'EventErr'
// EXPECT (after fix): prints `own EventErr.Boom`, exit 0.
//
// Proof it's the collision: rename `EventErr` -> `MyErr` and it compiles and
// prints. The reference side (`!EventErr` → resolveNominalLeaf) is already
// visibility-aware from issue 0132's broader fix, but it is dormant until the
// local declaration gets its own TypeId. See the .md.
#import "modules/std.sx";
EventErr :: error { Boom }
fail :: () -> !EventErr {
raise error.Boom;
}
main :: () -> i32 {
r := fail();
if r == error.Boom {
print("own EventErr.Boom\n");
return 0;
}
print("wrong set\n");
return 1;
}