mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
kernel.c: regression on struct/array/hash == override with super; fix #6660
when overriding struct#==, array#==, or hash#== with super, the recursion
detection incorrectly treated the super call as a circular reference. this
was caused by commit 5ca2d442 which added recursion detection.
the fix introduces mrb_recursive_func_p that starts from ci[-2] instead of
ci[-1], skipping the immediate parent frame which may be a ruby override
calling super. equality methods (==, eql?) now use this function, while
inspect methods keep using mrb_recursive_method_p for immediate circular
reference detection.
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -1890,7 +1890,7 @@ mrb_ary_eq(mrb_state *mrb, mrb_value ary1)
|
||||
if (n == 0) return mrb_false_value();
|
||||
|
||||
/* Check for recursion */
|
||||
if (MRB_RECURSIVE_BINARY_P(mrb, MRB_OPSYM(eq), ary1, ary2)) {
|
||||
if (MRB_RECURSIVE_BINARY_FUNC_P(mrb, MRB_OPSYM(eq), ary1, ary2)) {
|
||||
return mrb_false_value();
|
||||
}
|
||||
|
||||
@@ -1921,7 +1921,7 @@ mrb_ary_eql(mrb_state *mrb, mrb_value ary1)
|
||||
if (n == 0) return mrb_false_value();
|
||||
|
||||
/* Check for recursion */
|
||||
if (MRB_RECURSIVE_BINARY_P(mrb, MRB_SYM_Q(eql), ary1, ary2)) {
|
||||
if (MRB_RECURSIVE_BINARY_FUNC_P(mrb, MRB_SYM_Q(eql), ary1, ary2)) {
|
||||
return mrb_false_value();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user