Commit da759d8a

da759d8ac0ebMerged

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

Description

fix(codegen): don't widen lt to bigint via arg when recv is poly

(@h[k] ||= []) << bigint_lv — recv is the poly result of an ||= assignment, arg is a promote-widened bigint LV. The legacy widening at the top of compile_operator_expr saw the bigint arg and set lt to "bigint", routing through sp_bigint_shl on a poly recv. The poly-recv dispatch path (sp_poly_shl) is the right one.

Gate the widening: only fire when recv isn't poly / string / mutable_str. Those have their own per-type dispatch arms.

Promote-mode test errors: 25 -> 22. Default 631/0/0. Optcarrot wrap checksum 59662 unchanged.

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

Details

Commit
da759d8ac0eb
Parent
a8ee4ea26dac

spinel_codegen.rbmodifiedView file

@@ -15627,7 +15627,14 @@
1562715627 def compile_operator_expr(nid, mname, recv)
1562815628 # Bigint operators
1562915629 lt = infer_type(recv)
15630- if lt != "bigint"
15630+ # Don't widen lt to "bigint" via the arg-side promote when the
15631+ # recv is genuinely poly — the poly recv dispatch (sp_poly_shl
15632+ # / sp_poly_band etc.) is the correct path. `(@h[k] ||= []) <<
15633+ # v` where v is a promoted bigint LV would otherwise emit
15634+ # sp_bigint_shl on the poly recv. The legacy widening predates
15635+ # promote mode and assumed the arg-side bigint implied both
15636+ # operands were numeric.
15637+ if lt != "bigint" && lt != "poly" && lt != "string" && lt != "mutable_str"
1563115638 # Check if argument is bigint (direct type or via emit walker).
1563215639 args_id = @nd_arguments[nid]
1563315640 if args_id >= 0