Commit f4e69c34
f4e69c34cfdcMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): attr_writer stmt/expr forms coerce int rhs to bigint slot
Both the expression-form obj.attr = v at line 20389 and the
statement-form short-circuited attr_writer emit at line 28412
copied the raw rhs into a lv_p->iv_x = 10LL; shape. With promote
mode widening the ivar slot to sp_Bigint *, the literal int rhs
tripped -Wint-conversion.
Mirror the existing slot_t == "poly" boxing arm: when slot_t is
bigint and the rhs is int, wrap through sp_bigint_new_int;
reverse direction unboxes via sp_bigint_to_int.
Promote-mode test count: 476 pass / 54 fail / 88 error -> 480 pass / 54 fail / 84 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- f4e69c34cfdc
- Parent
- 33c8219ac984
spinel_codegen.rbmodifiedView file
boxed = box_value_to_poly(arg_t, tmp_w) return "({" + c_type(arg_t) + " " + tmp_w + " = " + arg0_w + "; " + rc + arrow + sanitize_ivar(bname) + " = " + boxed + "; " + tmp_w + ";})" end # promote-mode-widened ivar: wrap an int rhs through # sp_bigint_new_int. Mirror the bigint coerce branches at # the other ivar-write sites (line 24924, etc.). if slot_t == "bigint" arg_t_bw = "int" args_id_bw = @nd_arguments[nid] if args_id_bw >= 0 arg_ids_bw = get_args(args_id_bw) if arg_ids_bw.length > 0 arg_t_bw = infer_type(arg_ids_bw[0]) end end if arg_t_bw == "int" @needs_bigint = 1 return "(" + rc + arrow + sanitize_ivar(bname) + " = sp_bigint_new_int(" + arg0_w + "))" end end return "(" + rc + arrow + sanitize_ivar(bname) + " = " + arg0_w + ")" end j = j + 1 # expression-form attr_writer above. slot_t = cls_ivar_type(r_ci, "@" + bname) arg0_w = compile_arg0(nid) if slot_t == "poly" args_id_w = @nd_arguments[nid] arg_t = "int" if args_id_w >= 0 arg_ids_w = get_args(args_id_w) if arg_ids_w.length > 0 arg_t = infer_type(arg_ids_w[0]) end arg_t_aw = "int" args_id_aw = @nd_arguments[nid] if args_id_aw >= 0 arg_ids_aw = get_args(args_id_aw) if arg_ids_aw.length > 0 arg_t_aw = infer_type(arg_ids_aw[0]) end arg0_w = box_value_to_poly(arg_t, arg0_w) end if slot_t == "poly" arg0_w = box_value_to_poly(arg_t_aw, arg0_w) elsif slot_t == "bigint" && arg_t_aw == "int" # promote-mode-widened ivar: wrap an int rhs. @needs_bigint = 1 arg0_w = "sp_bigint_new_int(" + arg0_w + ")" elsif slot_t == "int" && arg_t_aw == "bigint" @needs_bigint = 1 arg0_w = "sp_bigint_to_int((sp_Bigint *)" + arg0_w + ")" end emit(" " + rc + arrow2 + sanitize_ivar(bname) + " = " + arg0_w + ";") return 1 end