Project

General

Profile

Actions

Bug #22708

open

UnboundMethod#inspect for ZSUPER method potentially shows undefined method since Ruby 3.2

Bug #22708: UnboundMethod#inspect for ZSUPER method potentially shows undefined method since Ruby 3.2

Added by jeremyevans0 (Jeremy Evans) about 8 hours ago. Updated about 6 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:127809]

Description

Starting in Ruby 3.2, UnboundMethod#inspect drops the class defining the ZSUPER method. Method#inspect always shows the class:

class C
  def c; 1 end
end

class SC < C
  alias sc c
end

p SC.instance_method(:sc)
# Ruby 2.2-2.6: #<UnboundMethod: SC(C)#sc(c)>
# Ruby 2.7-3.1: #<UnboundMethod: SC(C)#sc(c)() -:2>
# Ruby 3.2-4.0: #<UnboundMethod: C#sc(c)() -:2>

p SC.new.method(:sc)
# Ruby 2.2-2.6: #<Method: SC(C)#sc(c)>
# Ruby 2.7-4.0: #<Method: SC(C)#sc(c)() -:2>

The C#sc(c) for Ruby 3.2-4.0 seems wrong to me, because C#sc is not defined (SC#sc is defined). I think we should restore the Ruby 2.7-3.1 behavior for UnboundMethod#inspect, making it consistent with Method#inspect.

Updated by jeremyevans0 (Jeremy Evans) about 6 hours ago Actions #1 [ruby-core:127811]

From further analysis, the change was due to #18798, but discussion in that bug did not consider ZSUPER methods.

PR: https://github.com/ruby/ruby/pull/20434

Actions

Also available in: PDF Atom