Commit 71029dd5
71029dd5129dMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
codegen(promote): pad a missing required arg with boxed 0, not nil, in a poly slot
A call missing a required positional arg pads the slot with a zero-ish
compat value so codegen completes (a compile-time warning already flagged
it). An int slot emits 0; a promote-widened poly slot emitted
default_value(TY_POLY) = sp_box_nil(), which renders blank instead of the
0 the int path (and the test's pinned behaviour) produces. Emit
sp_box_int(0) for the poly case to mirror the scalar pad.
Fixes promote-mode missing_positional_arg_warns.
Default test 992/0/0 and optcarrot checksum 59662 unchanged.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 71029dd5129d
- Parent
- dec6767c6185
src/codegen_fold.cmodifiedView file
@@ -2826,7 +2826,12 @@
28262826
int dv = m->pdefault[idx];28272827
const char *dty = dv >= 0 ? nt_type(c->nt, dv) : NULL;28282828
if (dv < 0) {2829-
buf_puts(out, pt == TY_RANGE ? "(sp_Range){0}" : default_value(pt));2829+
/* A missing required arg pads the slot with a zero-ish compat value so2830+
codegen completes (a compile-time warning already flagged the call).2831+
A poly-widened slot must mirror the scalar `0` an int slot emits, not2832+
sp_box_nil() -- otherwise the padded value renders as blank. */2833+
if (pt == TY_POLY) buf_puts(out, "sp_box_int(0)");2834+
else buf_puts(out, pt == TY_RANGE ? "(sp_Range){0}" : default_value(pt));28302835
}28312836
else if (dty && !strcmp(dty, "NilNode")) {28322837
/* nil default: emit the nil sentinel for the type */