check: stamp SK_TYPE value idents with the per-decl NAMED
A TYPE name used as a VALUE (an error-singleton `return too_long;`) stamped the flattened BODY type, so structurally identical !void singletons in one union were indistinguishable and flatvariantidxt loud-rejected the ambiguity — the real cause of the lib/path wwstage reject (the pinned #120/#29 global-slice-const blame was stale; that family had drained). The N_IDENT arm resolves through a synthesized TNAME (the #66 N_STRUCTLIT precedent); the module-qualified N_DOT twin reads the sym's cached NAMED. Graduates the path M_WWREJECT pin (#142).
This commit is contained in:
@@ -3310,6 +3310,26 @@ fn exprtype(c: *checker, e: *syntax.node, hint: *syntax.node) *syntax.node = {
|
||||
e.type_ = tinfofornode(c, ft): *void;
|
||||
return ft;
|
||||
};
|
||||
// #142: a TYPE name used as a VALUE (an error-singleton
|
||||
// `return too_long;`) must stamp the per-decl NAMED, not the
|
||||
// flattened body — three structurally identical !void
|
||||
// singletons in one union are indistinguishable by body, so
|
||||
// flatvariantidxt's NAMED pass either mis-tags or
|
||||
// loud-rejects as ambiguous. Resolve through a synthesized
|
||||
// TNAME to reuse tinfofornode's TY_NAMED build/cache (the
|
||||
// SAME NAMED ptr the union variant resolved to) — the #66
|
||||
// N_STRUCTLIT precedent verbatim; cstage mirror
|
||||
// cmd/wcc/check.c:1414 `n->type = s->type`. The BODY node
|
||||
// still returns so AST-level assign/return checks keep
|
||||
// their prior input.
|
||||
if (s.skind == syntax.skind.SK_TYPE) {
|
||||
let tnm: *syntax.node = mktname(c, e.str);
|
||||
let nti: *syntax.tinfo = tinfofornode(c, tnm);
|
||||
if (nti != nil) {
|
||||
e.type_ = nti: *void;
|
||||
return s.decl.lhs;
|
||||
};
|
||||
};
|
||||
let t: *syntax.node = s.decl.lhs;
|
||||
// Propagate the declared type's tinfo onto the use site so
|
||||
// downstream cgen walkers can read n.type_ off an ident.
|
||||
@@ -3878,6 +3898,19 @@ fn exprtype(c: *checker, e: *syntax.node, hint: *syntax.node) *syntax.node = {
|
||||
e.type_ = tinfofornode(c, ft): *void;
|
||||
return ft;
|
||||
};
|
||||
// #142 twin of the N_IDENT SK_TYPE arm: a
|
||||
// module-qualified TYPE name used as a VALUE
|
||||
// (`mod.too_long`) stamps the per-decl NAMED.
|
||||
// The sym caches its NAMED (tinfofornode
|
||||
// N_TNAME arm) once any type-position ref
|
||||
// resolved; a nil cache falls through to the
|
||||
// prior body stamp.
|
||||
if (fs.skind == syntax.skind.SK_TYPE) {
|
||||
if (fs.type_ != nil) {
|
||||
e.type_ = fs.type_: *void;
|
||||
return fs.decl.lhs;
|
||||
};
|
||||
};
|
||||
let tn: *syntax.node = fs.decl.lhs;
|
||||
if (tn != nil) {
|
||||
e.type_ = tinfofornode(c, tn): *void;
|
||||
|
||||
Reference in New Issue
Block a user