Commit 1e3e8f15
1e3e8f15f6f1Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): array literal poly_array push peeks arith arg for bigint
compile_array_literal_as_poly and compile_array_literal_from _ids' poly_array arm called box_value_to_poly(et, val) with
et = infer_type(elem). A stale "int" for a CallNode + - * / % ** whose arg side was bigint caused box_value_to_poly to pick
the int arm (sp_box_int(val)) — passing the bigint emit
through as the int.
Peek operand types before calling box_value_to_poly to upgrade stale "int" to "bigint", so the unbox-then-box path fires.
Promote-mode test count: 548 pass / 48 fail / 22 error -> 548 pass / 49 fail / 21 error. Default raise mode 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 1e3e8f15f6f1
- Parent
- f45958d5a509
spinel_codegen.rbmodifiedView file
emit(" sp_PolyArray_push(" + tmp + ", sp_box_poly_array(" + conv + "));") else val = compile_expr(eid) # Stale cache may say "int" for an arith CallNode whose # actual emit is bigint. Promote at the box boundary so # box_value_to_poly's bigint arm fires (unbox + sp_box_int). if et != "bigint" && @nd_type[eid] == "CallNode" eml = @nd_name[eid] if eml == "+" || eml == "-" || eml == "*" || eml == "/" || eml == "%" || eml == "**" er = @nd_receiver[eid] if er >= 0 && base_type(infer_type(er)) == "bigint" et = "bigint" else ea = @nd_arguments[eid] if ea >= 0 aa_lit = get_args(ea) if aa_lit.length > 0 && base_type(infer_type(aa_lit[0])) == "bigint" et = "bigint" end end end end end emit(" sp_PolyArray_push(" + tmp + ", " + box_value_to_poly(et, val) + ");") end k = k + 1 emit(" sp_PolyArray_push(" + tmp + ", sp_box_poly_array(" + conv + "));") else val = compile_expr(elems[k]) # Stale cache may say "int" for an arith CallNode whose # actual emit is bigint. Promote at the box boundary so # box_value_to_poly's bigint arm fires. if et != "bigint" && @nd_type[elems[k]] == "CallNode" ear_mn = @nd_name[elems[k]] if ear_mn == "+" || ear_mn == "-" || ear_mn == "*" || ear_mn == "/" || ear_mn == "%" || ear_mn == "**" ear_r = @nd_receiver[elems[k]] if ear_r >= 0 && base_type(infer_type(ear_r)) == "bigint" et = "bigint" else ear_a = @nd_arguments[elems[k]] if ear_a >= 0 aa_ear = get_args(ear_a) if aa_ear.length > 0 && base_type(infer_type(aa_ear[0])) == "bigint" et = "bigint" end end end end end emit(" sp_PolyArray_push(" + tmp + ", " + box_value_to_poly(et, val) + ");") end k = k + 1