Commit f43a7ea7
f43a7ea7746cMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · ~2 modified
Description
fix: allow binary ops when both operands have VALUE type
When instance variable types are not fully inferred (e.g., attr_reader returning VALUE because initialize params default to VALUE), binary operators like == between two VALUE-typed expressions would fail with "unsupported: unknown#==". This fix allows binary ops to proceed when both sides are VALUE, since VALUE is mrb_int underneath.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- f43a7ea7746c
- Parent
- 8d18c5bdc9b9
src/expr.cmodifiedView file
@@ -749,6 +749,10 @@
749749
bool rt_ok = vt_is_numeric(rt) || rt.kind == SPINEL_TYPE_BOOLEAN;750750
if (!lt_ok && lt.kind == SPINEL_TYPE_VALUE && rt_ok) lt_ok = true;751751
if (!rt_ok && rt.kind == SPINEL_TYPE_VALUE && lt_ok) rt_ok = true;752+
/* Both VALUE: allow binary ops (VALUE is mrb_int underneath) */753+
if (!lt_ok && !rt_ok && lt.kind == SPINEL_TYPE_VALUE && rt.kind == SPINEL_TYPE_VALUE) {754+
lt_ok = true; rt_ok = true;755+
}752756
753757
if (c_op && lt_ok && rt_ok) {754758
char *left = codegen_expr(ctx, call->receiver);src/type.cmodifiedView file
Loading diff…