From 3eef2828c6a8908afdd5d63e3a1ee4fb8caaae50 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Fri, 22 May 2026 23:12:07 +0900 Subject: [PATCH] selfhost/cmd/wcc: stamp typed-suffix N_FLOATLIT (#51b) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cstage cmd/wcc/check.c:702 cexpr N_FLOATLIT arm uses lookup_builtin (n->tsuffix) with fall-through to ty_untyped_float. wwstage's exprtype N_FLOATLIT arm at check.ww L1582 was unconditional untyped_float — the symmetric-stage gap flagged at the tail of #51. 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_float path. Same shape as the #51 INTLIT arm one block up. 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 0f801c59..fa6ea27c 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -8650,6 +8650,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { return tn; }; if (k == nkind.N_FLOATLIT) { + // Typed-float literal (`1.5f32`, `0.0f64`): tsuffix names a + // builtin primitive. Mirrors cstage cmd/wcc/check.c:702-709 + // cexpr's `lookup_builtin(n->tsuffix)`; falls through to + // untyped_float 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_float"); e.type_ = tinfofornode(c, tn): *void; return tn; diff --git a/selfhost/cmd/wcc/check.ww b/selfhost/cmd/wcc/check.ww index c0820532..c6a39a79 100644 --- a/selfhost/cmd/wcc/check.ww +++ b/selfhost/cmd/wcc/check.ww @@ -1580,6 +1580,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { return tn; }; if (k == nkind.N_FLOATLIT) { + // Typed-float literal (`1.5f32`, `0.0f64`): tsuffix names a + // builtin primitive. Mirrors cstage cmd/wcc/check.c:702-709 + // cexpr's `lookup_builtin(n->tsuffix)`; falls through to + // untyped_float 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_float"); 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 157353f6..31455ace 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -8650,6 +8650,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = { return tn; }; if (k == nkind.N_FLOATLIT) { + // Typed-float literal (`1.5f32`, `0.0f64`): tsuffix names a + // builtin primitive. Mirrors cstage cmd/wcc/check.c:702-709 + // cexpr's `lookup_builtin(n->tsuffix)`; falls through to + // untyped_float 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_float"); e.type_ = tinfofornode(c, tn): *void; return tn;