Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong #inspect is used in Method#inspect #4995

Closed
apotonick opened this issue Jan 21, 2018 · 6 comments
Closed

Wrong #inspect is used in Method#inspect #4995

apotonick opened this issue Jan 21, 2018 · 6 comments

Comments

@apotonick
Copy link

Environment

  • JRuby version jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae OpenJDK 64-Bit Server VM 25.151-b12 on 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12 +jit [linux-x86_64]
  • Ubuntu 16.04

Expected Behavior

I override Module.inspect via a module (Inspect), A.inspect produces the correct result.

module Inspect
  def inspect
    "nice view!"
  end
end

module A
  extend Inspect

  def self.a
  end
end

A.inspect #=> "nice view!"

I am expecting the same inspect being used when inspecting a method instance from A.

puts A.method(:a).inspect #=> #<Method: nice view!.a>

This is the behavior in Ruby 2.5.

Actual Behavior

However, in Jruby it seems as if inspect doesn't use the correct version of A.inspect, but the original one.

# jruby 9.1.7
puts A.method(:a).inspect #=> #<Method: A.a>
@apotonick apotonick changed the title Wrong #inspect is used in Method.inspect Wrong #inspect is used in Method#inspect Jan 21, 2018
@headius
Copy link
Member

headius commented Jan 22, 2018

I have pushed a branch with fixes that re-align our Method#inspect logic with CRuby. Once it clears CI I'll merge.

@headius
Copy link
Member

headius commented Jan 22, 2018

@apotonick Can you put together a spec for ruby/spec?

@apotonick
Copy link
Author

Sure, @headius! Thanks for the fix!

In which directory would that go in ruby/spec? core/module ?

@headius
Copy link
Member

headius commented Jan 24, 2018

@apotonick core/method/inspect_spec.rb should do it.

Fix merged to 9.1 and master!

@headius headius added this to the JRuby 9.1.16.0 milestone Jan 24, 2018
@headius
Copy link
Member

headius commented Feb 1, 2018

@apotonick Still having trouble confirming the fix? I just ran it against 9.1.16 snapshot and it does indeed seem to be fixed:

$ jruby -v blah.rb
jruby 9.1.16.0-SNAPSHOT (2.3.3) 2018-02-01 74d4306 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [darwin-x86_64]
"nice view!"
"#<Method: nice view!.a>"

@apotonick
Copy link
Author

Sorry, I was being an idiot and still had my if Ruby == Jruby tests in place to make the wrong behavior pass. All good now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants