diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index 8e453e99..310883cb 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -8255,7 +8255,9 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { return t; }; if (k == nkind.N_CAST) { - // `expr: T` — explicit cast; the type expr is e.rhs. + // `expr: T` — explicit cast; the type expr is e.rhs. Mirrors + // cstage cmd/wcc/check.c:737 `n->type = resolve_type(c, n->rhs)`. + e.type_ = tinfofornode(c, e.rhs): *void; return e.rhs; }; if (k == nkind.N_CALL) { @@ -8396,11 +8398,15 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { if (taggedhaserr(c, ou)) { let v: *node = ou.list; for (v != nil) { - if (!iserrvariant(c, ou, v)) { return v; }; + if (!iserrvariant(c, ou, v)) { + e.type_ = tinfofornode(c, v): *void; + return v; + }; v = v.next; }; return nil; }; + e.type_ = tinfofornode(c, ou.list): *void; return ou.list; }; if (k == nkind.N_TRYUNW) { @@ -8414,20 +8420,28 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { if (taggedhaserr(c, ou)) { let v: *node = ou.list; for (v != nil) { - if (!iserrvariant(c, ou, v)) { return v; }; + if (!iserrvariant(c, ou, v)) { + e.type_ = tinfofornode(c, v): *void; + return v; + }; v = v.next; }; return nil; }; + e.type_ = tinfofornode(c, ou.list): *void; return ou.list; }; if (k == nkind.N_TYPEASSERT) { - // `e as T` → T + // `e as T` → T. Mirrors cstage cmd/wcc/check.c TYPEASSERT + // `n->type = resolve_type(c, n->rhs)`. + e.type_ = tinfofornode(c, e.rhs): *void; return e.rhs; }; if (k == nkind.N_TYPETEST) { // `e is T` → bool - return mktname(c, "bool"); + let tn: *node = mktname(c, "bool"); + e.type_ = tinfofornode(c, tn): *void; + return tn; }; return nil; }; diff --git a/selfhost/cmd/wcc/check.ww b/selfhost/cmd/wcc/check.ww index 36cde14b..297b7b07 100644 --- a/selfhost/cmd/wcc/check.ww +++ b/selfhost/cmd/wcc/check.ww @@ -1323,7 +1323,9 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { return t; }; if (k == nkind.N_CAST) { - // `expr: T` — explicit cast; the type expr is e.rhs. + // `expr: T` — explicit cast; the type expr is e.rhs. Mirrors + // cstage cmd/wcc/check.c:737 `n->type = resolve_type(c, n->rhs)`. + e.type_ = tinfofornode(c, e.rhs): *void; return e.rhs; }; if (k == nkind.N_CALL) { @@ -1464,11 +1466,15 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { if (taggedhaserr(c, ou)) { let v: *node = ou.list; for (v != nil) { - if (!iserrvariant(c, ou, v)) { return v; }; + if (!iserrvariant(c, ou, v)) { + e.type_ = tinfofornode(c, v): *void; + return v; + }; v = v.next; }; return nil; }; + e.type_ = tinfofornode(c, ou.list): *void; return ou.list; }; if (k == nkind.N_TRYUNW) { @@ -1482,20 +1488,28 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { if (taggedhaserr(c, ou)) { let v: *node = ou.list; for (v != nil) { - if (!iserrvariant(c, ou, v)) { return v; }; + if (!iserrvariant(c, ou, v)) { + e.type_ = tinfofornode(c, v): *void; + return v; + }; v = v.next; }; return nil; }; + e.type_ = tinfofornode(c, ou.list): *void; return ou.list; }; if (k == nkind.N_TYPEASSERT) { - // `e as T` → T + // `e as T` → T. Mirrors cstage cmd/wcc/check.c TYPEASSERT + // `n->type = resolve_type(c, n->rhs)`. + e.type_ = tinfofornode(c, e.rhs): *void; return e.rhs; }; if (k == nkind.N_TYPETEST) { // `e is T` → bool - return mktname(c, "bool"); + let tn: *node = mktname(c, "bool"); + e.type_ = tinfofornode(c, tn): *void; + return tn; }; return nil; }; diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index d20c1ab1..0e2539a2 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -8255,7 +8255,9 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { return t; }; if (k == nkind.N_CAST) { - // `expr: T` — explicit cast; the type expr is e.rhs. + // `expr: T` — explicit cast; the type expr is e.rhs. Mirrors + // cstage cmd/wcc/check.c:737 `n->type = resolve_type(c, n->rhs)`. + e.type_ = tinfofornode(c, e.rhs): *void; return e.rhs; }; if (k == nkind.N_CALL) { @@ -8396,11 +8398,15 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { if (taggedhaserr(c, ou)) { let v: *node = ou.list; for (v != nil) { - if (!iserrvariant(c, ou, v)) { return v; }; + if (!iserrvariant(c, ou, v)) { + e.type_ = tinfofornode(c, v): *void; + return v; + }; v = v.next; }; return nil; }; + e.type_ = tinfofornode(c, ou.list): *void; return ou.list; }; if (k == nkind.N_TRYUNW) { @@ -8414,20 +8420,28 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { if (taggedhaserr(c, ou)) { let v: *node = ou.list; for (v != nil) { - if (!iserrvariant(c, ou, v)) { return v; }; + if (!iserrvariant(c, ou, v)) { + e.type_ = tinfofornode(c, v): *void; + return v; + }; v = v.next; }; return nil; }; + e.type_ = tinfofornode(c, ou.list): *void; return ou.list; }; if (k == nkind.N_TYPEASSERT) { - // `e as T` → T + // `e as T` → T. Mirrors cstage cmd/wcc/check.c TYPEASSERT + // `n->type = resolve_type(c, n->rhs)`. + e.type_ = tinfofornode(c, e.rhs): *void; return e.rhs; }; if (k == nkind.N_TYPETEST) { // `e is T` → bool - return mktname(c, "bool"); + let tn: *node = mktname(c, "bool"); + e.type_ = tinfofornode(c, tn): *void; + return tn; }; return nil; };