[ruby-core:122558] [Ruby Bug#21446] StackOverflow when changing visibility in reopened refinement

Issue #21446 has been reported by luke-gru (Luke Gruber). ---------------------------------------- Bug #21446: StackOverflow when changing visibility in reopened refinement https://bugs.ruby-lang.org/issues/21446 * Author: luke-gru (Luke Gruber) * Status: Open * ruby -v: 3.5.0 * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- ```ruby class A def a :a end end class B < A end module R refine B do private :a end end module R refine B do public :a end end using R B.new.a # StackOverflow ``` I would expect it to change the visibility, not to overflow the stack. -- https://bugs.ruby-lang.org/

Issue #21446 has been updated by nobu (Nobuyoshi Nakada). It does not seem to need to reopen the refinement. Reproduces just by changing visibility twice. ```ruby module R refine B do private :a public :a end end ``` ---------------------------------------- Bug #21446: StackOverflow when changing visibility in reopened refinement https://bugs.ruby-lang.org/issues/21446#change-113791 * Author: luke-gru (Luke Gruber) * Status: Open * ruby -v: 3.5.0 * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- ```ruby class A def a :a end end class B < A end module R refine B do private :a end end module R refine B do public :a end end using R B.new.a # StackOverflow ``` I would expect it to change the visibility, not to overflow the stack. -- https://bugs.ruby-lang.org/

Issue #21446 has been updated by jeremyevans0 (Jeremy Evans). I found that you don't even need to change the visibility twice. This issue affects all refinement visibility change methods where the method whose visibility is changed by the refinement is in an ancestor of the refined class. Here's a simplified example: ```ruby class A private def a :a end end class B < A end module R refine B do public :a end end using R p B.new.a ``` I've submitted a pull request that handles this case: https://github.com/ruby/ruby/pull/14817 ---------------------------------------- Bug #21446: StackOverflow when changing visibility in reopened refinement https://bugs.ruby-lang.org/issues/21446#change-114831 * Author: luke-gru (Luke Gruber) * Status: Open * ruby -v: 3.5.0 * Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED ---------------------------------------- ```ruby class A def a :a end end class B < A end module R refine B do private :a end end module R refine B do public :a end end using R B.new.a # StackOverflow ``` I would expect it to change the visibility, not to overflow the stack. -- https://bugs.ruby-lang.org/
participants (3)
-
jeremyevans0 (Jeremy Evans)
-
luke-gru (Luke Gruber)
-
nobu (Nobuyoshi Nakada)