From 74e0923629398fdfc3bd8425f5aa9d89d1fab285 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sat, 21 Feb 2026 03:38:20 -0600 Subject: [PATCH] don't drop type info from add --- mcode.cm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mcode.cm b/mcode.cm index dea7ebc4..beb659f8 100644 --- a/mcode.cm +++ b/mcode.cm @@ -411,20 +411,24 @@ var mcode = function(ast) { // emit_numeric_binop: emit type-guarded numeric binary op // reads _bp_dest, _bp_left, _bp_right, _bp_ln, _bp_rn from closure var emit_numeric_binop = function(op_str) { - if ((is_known_number(_bp_ln) || slot_is_num(_bp_left)) - && (is_known_number(_bp_rn) || slot_is_num(_bp_right))) { + var left_known = is_known_number(_bp_ln) || slot_is_num(_bp_left) + var right_known = is_known_number(_bp_rn) || slot_is_num(_bp_right) + if (left_known && right_known) { emit_3(op_str, _bp_dest, _bp_left, _bp_right) mark_slot(_bp_dest, "num") return null } var t0 = alloc_slot() - var t1 = alloc_slot() var err = gen_label("num_err") var done = gen_label("num_done") - emit_2("is_num", t0, _bp_left) - emit_jump_cond("jump_false", t0, err) - emit_2("is_num", t1, _bp_right) - emit_jump_cond("jump_false", t1, err) + if (!left_known) { + emit_2("is_num", t0, _bp_left) + emit_jump_cond("jump_false", t0, err) + } + if (!right_known) { + emit_2("is_num", t0, _bp_right) + emit_jump_cond("jump_false", t0, err) + } emit_3(op_str, _bp_dest, _bp_left, _bp_right) emit_jump(done) @@ -1499,7 +1503,6 @@ var mcode = function(ast) { if (level == 0 || level == -1) { slot = find_var(name) if (slot >= 0) { - mark_slot(slot, null) val_slot = gen_expr(right, slot) if (val_slot != slot) { emit_2("move", slot, val_slot)