From 1ce0f638bfb609bea6bc9496bf3640f9b82bd245 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Fri, 22 May 2026 22:55:54 +0900 Subject: [PATCH] selfhost/cmd/wcc: stamp typed-suffix N_INTLIT (#51, #52 precursor) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cstage cmd/wcc/check.c:694 cexpr N_INTLIT arm uses lookup_builtin (n->tsuffix) with fall-through to ty_untyped_int. wwstage's exprtype N_INTLIT arm at check.ww L1565 was unconditional untyped_int — a symmetric-stage gap that left the last raw-str-typed reads of TNAME.str / INTLIT.tsuffix alive in typenodeprimresolved / exprprimresolved (the deferrals named at the end of A.6.3a, #45). New arm: when e.tsuffix is non-empty, mktname+tinfofornode resolves the builtin and stamps e.type_; on nil tinfo fall through to the existing untyped_int path. Mirrors harec ref/harec/src/check.c check_expr_literal routing typed ICONST through builtin_type_for_storage. N_FLOATLIT at check.ww:1582 carries the same gap (cstage check.c:702 does the same lookup_builtin/untyped_float fall-through); filed as #51b for a separate bisect-clean follow-up. This is the additive stamp half; #52 collapses the two remaining typenameisunsigned callers onto tinfo reads of the stamped type_. Byte-identity (994/995) is the behavior gate; full make test green at 133/133 confirms. --- selfhost/cmd/w6c/main.combined.ww | 12 ++++++++++++ selfhost/cmd/wcc/check.ww | 12 ++++++++++++ selfhost/cmd/wwdump/main.combined.ww | 12 ++++++++++++ 3 files changed, 36 insertions(+) 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;