Commit d09242b1
d09242b15e00Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): cvar write coerces rhs to cvar's static type
compile_stmt's ClassVariableWriteNode arm used raw
compile_expr + emit, leaving promote-widened bigint rhs values
unwrapped against an int cvar slot. Route through compile_expr
_for_expected_type with the cvar's recorded type so the helper's
int<->bigint coerce kicks in.
Promote-mode test count: 518 pass / 48 fail / 52 error -> 519 pass / 48 fail / 51 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- d09242b15e00
- Parent
- dbd67a423fd8
spinel_codegen.rbmodifiedView file
@@ -24792,8 +24792,15 @@
2479224792
# there (e.g. inside a class-method that pre-pass missed) we2479324793
# register defensively.2479424794
qname = cvar_qname(@current_class_idx, @nd_name[nid])24795-
val = compile_expr(@nd_expression[nid])24796-
val_t = infer_type(@nd_expression[nid])24795+
ci_cv_pre = find_cvar_idx(qname)24796+
cv_slot_t_pre = ci_cv_pre >= 0 ? @cvar_types[ci_cv_pre] : ""24797+
if cv_slot_t_pre == "" || cv_slot_t_pre == ""24798+
val = compile_expr(@nd_expression[nid])24799+
val_t = infer_type(@nd_expression[nid])24800+
else24801+
val = compile_expr_for_expected_type(@nd_expression[nid], cv_slot_t_pre)24802+
val_t = cv_slot_t_pre24803+
end2479724804
register_cvar(qname, val_t)2479824805
emit(" cvar_" + qname + " = " + val + ";")2479924806
return