Commit 01b8238c

01b8238c47faMerged

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

Description

fix(codegen): expr_emit_is_bigint guards expected-type bigint wrap

compile_expr_for_expected_type's bigint <- int arm now consults expr_emit_is_bigint so a stale-int rhs whose actual emit is sp_Bigint * skips the sp_bigint_new_int wrap and just casts.

Default 631/0/0.

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

Details

Commit
01b8238c47fa
Parent
e5b9da671df3

spinel_codegen.rbmodifiedView file

@@ -5845,6 +5845,12 @@
58455845 # few stdlib helpers still want mrb_int -- sp_bigint_to_int
58465846 # covers that.
58475847 if expected_base == "bigint" && at == "int"
5848+ # When the rhs's actual emit is already sp_Bigint * (a stale
5849+ # int cache hiding a bigint chain or user-method bigint
5850+ # return), skip the sp_bigint_new_int wrap.
5851+ if expr_emit_is_bigint(nid) == 1
5852+ return "(sp_Bigint *)" + val
5853+ end
58485854 @needs_bigint = 1
58495855 return "sp_bigint_new_int(" + val + ")"
58505856 end