Commit 55cf625b
55cf625b0328Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Fix cross-type equality, bare module-body calls, obj.!= synthesis
- primitive == user_object: numeric types delegate to object's == (Integer's Numeric#== calls other.==(self) for non-numerics); string/symbol/bool are strict (false)
- obj == nil: skip nil short-circuit when receiver is user object so the object's own == method is called instead
- obj != synthesized from obj.== when != is not explicitly defined
- bare call inside module/class body resolves to the enclosing module's class method (g_class_body_id context for both analyze and codegen)
- emit_arg_or_default: when argument type is TY_UNKNOWN due to unresolved bare class-method call, re-infer via g_class_body_id
Closes #primitive_eq_user_class, #bare_arg_in_module_body
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- 55cf625b0328
- Parent
- 0cbe0906a41d
src/analyze.cmodifiedView file
@@ -1055,6 +1055,11 @@
10551055
}10561056
}10571057
1058+
/* bare call inside a module/class body -> class method of that module/class */1059+
if (recv < 0 && g_cbody_class_id >= 0) {1060+
int smi = comp_cmethod_in_chain(c, g_cbody_class_id, name, NULL);1061+
if (smi >= 0) return method_call_ret(c, smi, id);1062+
}10581063
/* user-defined free-function call (no receiver) */10591064
if (recv < 0) {10601065
int mi = comp_method_index(c, name);src/codegen.cmodifiedView file
Loading diff…