Commit ca31a2aa
ca31a2aa41c1Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Support multi-arg push/append on typed arrays (statement position)
a.push(2, 3) / a.append(4, 5, 6) push each argument in turn.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- ca31a2aa41c1
- Parent
- b1932254bc1d
src/codegen.cmodifiedView file
@@ -1159,11 +1159,13 @@
11591159
emit_expr(c, argv[1], b); buf_puts(b, ");\n");11601160
return 1;11611161
}1162-
if ((!strcmp(name, "push") || !strcmp(name, "<<")) && argc == 1) {1163-
emit_indent(b, indent);1164-
buf_printf(b, "sp_%sArray_push(", k);1165-
emit_expr(c, recv, b); buf_puts(b, ", ");1166-
emit_expr(c, argv[0], b); buf_puts(b, ");\n");1162+
if ((!strcmp(name, "push") || !strcmp(name, "<<") || !strcmp(name, "append")) && argc >= 1) {1163+
for (int a = 0; a < argc; a++) {1164+
emit_indent(b, indent);1165+
buf_printf(b, "sp_%sArray_push(", k);1166+
emit_expr(c, recv, b); buf_puts(b, ", ");1167+
emit_expr(c, argv[a], b); buf_puts(b, ");\n");1168+
}11671169
return 1;11681170
}11691171
return 0;