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 rawcompile_exprand 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
emit(" " + c_type(rt) + " " + tmp + " = " + c_default_val(rt) + ";") emit(" sp_exc_top++;") emit(" if (setjmp(sp_exc_stack[sp_exc_top-1]) == 0) {") emit(" " + tmp + " = " + compile_expr(@nd_expression[nid]) + ";") emit(" " + tmp + " = " + compile_expr_for_expected_type(@nd_expression[nid], rt) + ";") emit(" sp_exc_top--;") emit(" } else {") emit(" sp_exc_top--;") emit(" " + tmp + " = " + compile_expr(@nd_else_clause[nid]) + ";") emit(" " + tmp + " = " + compile_expr_for_expected_type(@nd_else_clause[nid], rt) + ";") emit(" }") return tmp end return "sp_str_dup(" + rc + ")" end if mname == "getbyte" return "((mrb_int)(unsigned char)(" + rc + ")[" + compile_arg0(nid) + "])" return "((mrb_int)(unsigned char)(" + rc + ")[" + compile_arg0_as_int(nid) + "])" end if mname == "setbyte" # `s.setbyte(i, v)` mutates the receiver in place. Spinel