str stone; concat

This commit is contained in:
2026-02-20 21:54:19 -06:00
parent a82c13170f
commit fca1041e52
9 changed files with 389 additions and 15 deletions

View File

@@ -1514,8 +1514,10 @@ var mcode = function(ast) {
// Standard binary ops
left_slot = gen_expr(left, -1)
right_slot = gen_expr(right, -1)
// Use target slot for ops without multi-type dispatch (add has text+num paths)
dest = (target >= 0 && kind != "+") ? target : alloc_slot()
// Use target slot for ops without multi-type dispatch (add has text+num paths).
// Exception: allow + to write directly to target when target == left_slot
// (self-assign pattern like s = s + x) since concat/add reads before writing.
dest = (target >= 0 && (kind != "+" || target == left_slot)) ? target : alloc_slot()
op = binop_map[kind]
if (op == null) {
op = "add"