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;