Project

General

Profile

Actions

Bug #22616

closed

SystemStackError from `super` when refining a method from a module that appears twice in ancestry

Bug #22616: SystemStackError from `super` when refining a method from a module that appears twice in ancestry

Added by alanwu (Alan Wu) 1 day ago. Updated 1 day ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:127653]

Description

class C0; end; class C1 < C0; end
module M1; end
c0 = C0.new
c1 = C1.new.extend(M1)
module R1; refine(M1) { def m = super }; end
C0.prepend M1
p c1.singleton_class.ancestors # [#<singleton>, M1, C1, M1, C0, ...]

using R1
c1.m # SystemStackError; should be NoMethodError
c0.m # SystemStackError too, but NoMethodError if the line above is removed

Bisected to 3a66844fa9 [Feature #22309], so trunk-only.

Updated by shugo (Shugo Maeda) 1 day ago Actions #1

  • Status changed from Open to Closed

Applied in changeset git|6e687b542739799d4d92a658b79652a486246282.


Fix infinite super recursion in a refinement of a module included twice

When super skips the current refinement method and finds the refined
entry of the second inclusion, vm_call_refined resolved it in a second
pass and cached the refinement method for the second iclass, which is
where super in that method starts its lookup. Resolve such an entry
in search_refined_method so that the result is cached for the class
the search started from.

[Bug #22616]

Co-Authored-By: Claude Fable 5.2

Actions

Also available in: PDF Atom