Commit bbae0e91

bbae0e91c820Merged

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

Description

fix(codegen): unary minus on bigint receiver dispatches sp_bigint_sub

Both - (with no args) and -@ unary-minus paths emitted raw C (-recv) for non-poly receivers. On a promote-widened bigint receiver, this tried to negate a pointer (-sp_Bigint *), tripping "wrong type argument to unary minus".

Route through sp_bigint_sub(sp_bigint_new_int(0), recv) when the receiver is bigint — there's no dedicated sp_bigint_neg helper, so synthesize via 0-minus.

Promote-mode test count: 519 pass / 48 fail / 51 error -> 519 pass / 49 fail / 50 error. Default raise mode unchanged at 618 / 0 / 0.

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

Details

Commit
bbae0e91c820
Parent
d09242b15e00

spinel_codegen.rbmodifiedView file

@@ -15165,6 +15165,10 @@
1516515165 if lt == "int"
1516615166 return "sp_int_neg(" + compile_expr(recv) + ")"
1516715167 end
15168+ if lt == "bigint"
15169+ @needs_bigint = 1
15170+ return "sp_bigint_sub(sp_bigint_new_int(0), (sp_Bigint *)" + compile_expr(recv) + ")"
15171+ end
1516815172 return "(-" + compile_expr(recv) + ")"
1516915173 end
1517015174 if lt == "poly"
@@ -15645,6 +15649,10 @@
1564515649 if rt == "float"
1564615650 return "(-" + compile_expr(recv) + ")"
1564715651 end
15652+ if rt == "bigint"
15653+ @needs_bigint = 1
15654+ return "sp_bigint_sub(sp_bigint_new_int(0), (sp_Bigint *)" + compile_expr(recv) + ")"
15655+ end
1564815656 return "(-" + compile_expr(recv) + ")"
1564915657 end
1565015658 ""