Commit 5001c496
5001c4964b01Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): string-coerce bigint values in interpolation and str concat / append
Three sites assumed any integer-tagged value coerces through
sp_int_to_s, but a promote-mode-widened Integer LV is now
sp_Bigint * and a raw sp_int_to_s(<ptr>) rejects under
-Wint-conversion (and would print a pointer cast, even if it
compiled):
compile_interpolated—"#{n}"for a bigint n; route through sp_bigint_to_s via the existing%sformat slot.collect_concat_parts(str + bigint + ...chains) — splice an sp_bigint_to_s call into the str_concat parts list.String <<mutating append on a mutable_str — same.
Promote-mode test count: 480 pass / 55 fail / 83 error -> 494 pass / 43 fail / 81 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 5001c4964b01
- Parent
- 3dad6a2f4392
spinel_codegen.rbmodifiedView file
@@ -12132,6 +12132,13 @@
1213212132
if it == "int"1213312133
fmt = fmt + "%lld"1213412134
arg_exprs.push("(long long)" + compile_expr(inner))12135+
elsif it == "bigint"12136+
# promote-mode interpolation of an Integer LV: route12137+
# through sp_bigint_to_s so the displayed value is the12138+
# bigint's decimal repr, not a pointer cast to long long.12139+
@needs_bigint = 112140+
fmt = fmt + "%s"12141+
arg_exprs.push("sp_bigint_to_s((sp_Bigint *)" + compile_expr(inner) + ")")1213512142
else1213612143
if it == "float"1213712144
# CRuby's Float#to_s (which is what `"#{x}"` calls)@@ -14873,6 +14880,9 @@
1487314880
parts.push(compile_expr(aargs[0]))1487414881
elsif at == "int"1487514882
parts.push("sp_int_to_s(" + compile_expr(aargs[0]) + ")")14883+
elsif at == "bigint"14884+
@needs_bigint = 114885+
parts.push("sp_bigint_to_s((sp_Bigint *)" + compile_expr(aargs[0]) + ")")1487614886
elsif at == "float"1487714887
parts.push("sp_float_to_s(" + compile_expr(aargs[0]) + ")")1487814888
else@@ -27449,6 +27459,9 @@
2744927459
val = compile_expr(argl[0])2745027460
if at == "int"2745127461
emit(" sp_String_append(" + rc + ", sp_int_to_s(" + val + "));")27462+
elsif at == "bigint"27463+
@needs_bigint = 127464+
emit(" sp_String_append(" + rc + ", sp_bigint_to_s((sp_Bigint *)" + val + "));")2745227465
else2745327466
if at == "mutable_str"2745427467
emit(" sp_String_append(" + rc + ", " + val + "->data);")