Commit 54c24da8
54c24da867aeMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): override stale cached type for obj.method / bare cmeth calls in promote mode
compile_expr_for_expected_type's post-promotion arithmetic
override covered + - * / % etc. but not regular method calls,
so a CallNode like @w.grab (where Wrapper#grab's return slot
was promoted to bigint) still picked up the stale "int" annotation
filled by annotate_all_node_types and got double-wrapped via
sp_bigint_new_int.
Extend the override to consult cls_method_return directly when
at != bigint:
obj.methodwith an obj-typed recv -> look up the recv's class.- bare receiver (
targetinside a class body) -> look up under@current_class_idx.
Promote-mode test count: 466 pass / 46 fail / 106 error -> 467 pass / 46 fail / 105 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 54c24da867ae
- Parent
- 6ab20447be4f
spinel_codegen.rbmodifiedView file
end end end # Same shape for an `obj.method` call: cached type may be the # pre-promotion "int", but cls_method_return is now bigint after # the global promote. Mirror infer_call_type's obj-arm so the # emitted call's actual return type drives the coerce decision. if at != "bigint" && cm_recv_p >= 0 recv_t_p = base_type(infer_type(cm_recv_p)) if is_obj_type(recv_t_p) == 1 rcname_p = recv_t_p[4, recv_t_p.length - 4] rci_p = find_class_idx(rcname_p) if rci_p >= 0 mr_p = cls_method_return(rci_p, cm_mn_p) if base_type(mr_p) == "bigint" at = "bigint" end end end end # Bare call inside a class body (recv < 0) — same staleness # for `target` inside `def foo(opt = target)` where target's # return slot got promoted. if at != "bigint" && cm_recv_p < 0 && @current_class_idx >= 0 mr_b = cls_method_return(@current_class_idx, cm_mn_p) if base_type(mr_b) == "bigint" at = "bigint" end end end # `if v.is_a?(String); helper(v); end` (and analogues for int / # float / sym / obj) — `v`'s C storage is sp_RbVal but the