diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index f01a0f77..0f801c59 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -8633,6 +8633,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { // node.type_ as the SSoT; populating literals + idents closes the // loop from the read side. if (k == nkind.N_INTLIT) { + // Typed-int literal (`7u32`, `0i8`): tsuffix names a builtin + // primitive. Mirrors cstage cmd/wcc/check.c:694-701 cexpr's + // `lookup_builtin(n->tsuffix)`; falls through to untyped_int + // when the suffix doesn't resolve. + if (e.tsuffix.len > 0) { + let suf: *node = mktname(c, e.tsuffix); + let ti: *tinfo = tinfofornode(c, suf); + if (ti != nil) { + e.type_ = ti: *void; + return suf; + }; + }; let tn: *node = mktname(c, "untyped_int"); e.type_ = tinfofornode(c, tn): *void; return tn; diff --git a/selfhost/cmd/wcc/check.ww b/selfhost/cmd/wcc/check.ww index 747d24f7..c0820532 100644 --- a/selfhost/cmd/wcc/check.ww +++ b/selfhost/cmd/wcc/check.ww @@ -1563,6 +1563,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { // node.type_ as the SSoT; populating literals + idents closes the // loop from the read side. if (k == nkind.N_INTLIT) { + // Typed-int literal (`7u32`, `0i8`): tsuffix names a builtin + // primitive. Mirrors cstage cmd/wcc/check.c:694-701 cexpr's + // `lookup_builtin(n->tsuffix)`; falls through to untyped_int + // when the suffix doesn't resolve. + if (e.tsuffix.len > 0) { + let suf: *node = mktname(c, e.tsuffix); + let ti: *tinfo = tinfofornode(c, suf); + if (ti != nil) { + e.type_ = ti: *void; + return suf; + }; + }; let tn: *node = mktname(c, "untyped_int"); e.type_ = tinfofornode(c, tn): *void; return tn; diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index 35091826..157353f6 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -8633,6 +8633,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { // node.type_ as the SSoT; populating literals + idents closes the // loop from the read side. if (k == nkind.N_INTLIT) { + // Typed-int literal (`7u32`, `0i8`): tsuffix names a builtin + // primitive. Mirrors cstage cmd/wcc/check.c:694-701 cexpr's + // `lookup_builtin(n->tsuffix)`; falls through to untyped_int + // when the suffix doesn't resolve. + if (e.tsuffix.len > 0) { + let suf: *node = mktname(c, e.tsuffix); + let ti: *tinfo = tinfofornode(c, suf); + if (ti != nil) { + e.type_ = ti: *void; + return suf; + }; + }; let tn: *node = mktname(c, "untyped_int"); e.type_ = tinfofornode(c, tn): *void; return tn;