Commit bd0798cc

bd0798ccbcbbMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

fix(codegen): RescueModifier + String#getbyte coerce bigint

  • RescueModifierNode (expr rescue fallback) compiled both arms with raw compile_expr and assigned into a typed temp. When the temp's union type was int but one of the arms returned a promote-widened bigint, the assignment tripped -Wint-conversion. Route both arms through compile_expr_for _expected_type(arm, rt) so the helper's int<->bigint coerce branches fire.

  • String#getbyte(i) lowered to (rc)[compile_arg0(...)]. With promote mode making the index a bigint local, the C array subscript saw a pointer instead of mrb_int. Use compile_arg0 _as_int which already unboxes via sp_bigint_to_int.

Promote-mode test count: 512 pass / 47 fail / 59 error -> 514 pass / 47 fail / 57 error. Default raise mode unchanged at 618 / 0 / 0.

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
bd0798ccbcbb
Parent
abbf1aa436d5

spinel_codegen.rbmodifiedView file

@@ -11867,11 +11867,11 @@
1186711867 emit(" " + c_type(rt) + " " + tmp + " = " + c_default_val(rt) + ";")
1186811868 emit(" sp_exc_top++;")
1186911869 emit(" if (setjmp(sp_exc_stack[sp_exc_top-1]) == 0) {")
11870- emit(" " + tmp + " = " + compile_expr(@nd_expression[nid]) + ";")
11870+ emit(" " + tmp + " = " + compile_expr_for_expected_type(@nd_expression[nid], rt) + ";")
1187111871 emit(" sp_exc_top--;")
1187211872 emit(" } else {")
1187311873 emit(" sp_exc_top--;")
11874- emit(" " + tmp + " = " + compile_expr(@nd_else_clause[nid]) + ";")
11874+ emit(" " + tmp + " = " + compile_expr_for_expected_type(@nd_else_clause[nid], rt) + ";")
1187511875 emit(" }")
1187611876 return tmp
1187711877 end
@@ -16628,7 +16628,7 @@
1662816628 return "sp_str_dup(" + rc + ")"
1662916629 end
1663016630 if mname == "getbyte"
16631- return "((mrb_int)(unsigned char)(" + rc + ")[" + compile_arg0(nid) + "])"
16631+ return "((mrb_int)(unsigned char)(" + rc + ")[" + compile_arg0_as_int(nid) + "])"
1663216632 end
1663316633 if mname == "setbyte"
1663416634 # `s.setbyte(i, v)` mutates the receiver in place. Spinel