Commit 0d2870c7
0d2870c78eeeMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
puts nil prints a blank line
emit_puts_one handles a nil argument (e.g. puts nil, puts nil.itself) by
evaluating it and printing a newline, instead of failing on the NilNode.
make test: 185 pass / 6 fail / 653 error (was 184 / 6 / 654); puts_nil green, no regressions.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 0d2870c78eee
- Parent
- 496902126914
src/codegen.cmodifiedView file
@@ -2812,6 +2812,9 @@
28122812
({ int _n = 0; nt_arr(c->nt, arg, "elements", &_n); _n == 0; })) {28132813
buf_puts(b, "(void)0; /* puts [] prints nothing */\n");28142814
}2815+
else if (t == TY_NIL) {2816+
buf_puts(b, "(void)("); emit_expr(c, arg, b); buf_puts(b, "); putchar('\\n'); /* puts nil */\n");2817+
}28152818
else {28162819
unsupported(c, arg, "puts argument");28172820
}