Commit fa08c47c
fa08c47c15e5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): bigint_arg peeks user-method + attr_reader returns
compile_bigint_arg's peek already handled arith CallNodes whose
arg was bigint. Extend it to also catch:
- user-method CallNodes whose recv class's
cls_method_returnresolves to bigint (post-promote); - attr_reader CallNodes — auto-generated, return type follows the ivar slot — by consulting cls_ivar_type when the recv class has an attr_reader for the method name.
Without this, total + vv.sum (Vec#sum attr_reader, @sum slot
bigint) wrapped the already-bigint emit (lv_vv->iv_sum) with
sp_bigint_new_int again.
Promote-mode test count: 537 pass / 53 fail / 28 error -> 537 pass / 54 fail / 27 error. Default raise mode 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- fa08c47c15e5
- Parent
- 07f393361b34
spinel_codegen.rbmodifiedView file
@@ -15036,9 +15036,10 @@
1503615036
if arg_ids.length > 01503715037
at = infer_type(arg_ids[0])1503815038
# The cache may say "int" even though the arg emits bigint15039-
# (arith CallNode with bigint operand). Peek operands so we15040-
# don't wrap an already-bigint expression with sp_bigint_new15041-
# _int.15039+
# (arith CallNode with bigint operand, or an attr-reader / user-15040+
# method call whose return slot is now promoted). Peek operands15041+
# / consult the post-promote method-return tables so we don't15042+
# wrap an already-bigint expression with sp_bigint_new_int.1504215043
if at != "bigint" && @nd_type[arg_ids[0]] == "CallNode"1504315044
ar_mn_bg = @nd_name[arg_ids[0]]1504415045
if ar_mn_bg == "+" || ar_mn_bg == "-" || ar_mn_bg == "*" || ar_mn_bg == "/" || ar_mn_bg == "%" || ar_mn_bg == "**"@@ -15055,6 +15056,31 @@
1505515056
end1505615057
end1505715058
end15059+
# `obj.method` call: re-resolve through cls_method_return on the15060+
# now-promoted table. Stale cache may say "int". Also check15061+
# attr_reader directly (auto-generated, ivar-slot-typed).15062+
if at != "bigint"15063+
recv_bgp = @nd_receiver[arg_ids[0]]15064+
if recv_bgp >= 015065+
recv_t_bgp = base_type(infer_type(recv_bgp))15066+
if is_obj_type(recv_t_bgp) == 115067+
cn_bgp = recv_t_bgp[4, recv_t_bgp.length - 4]15068+
ci_bgp = find_class_idx(cn_bgp)15069+
if ci_bgp >= 015070+
mr_bgp = cls_method_return(ci_bgp, ar_mn_bg)15071+
if base_type(mr_bgp) == "bigint"15072+
at = "bigint"15073+
end15074+
if at != "bigint" && cls_has_attr_reader(ci_bgp, ar_mn_bg) == 115075+
slot_bgp = cls_ivar_type(ci_bgp, "@" + ar_mn_bg)15076+
if base_type(slot_bgp) == "bigint"15077+
at = "bigint"15078+
end15079+
end15080+
end15081+
end15082+
end15083+
end1505815084
end1505915085
val = compile_expr(arg_ids[0])1506015086
if at == "bigint"