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

**operator behavior is different from MRI #4210

Closed
pbl-pw opened this Issue Oct 6, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@pbl-pw
Copy link

pbl-pw commented Oct 6, 2016

class AA < BasicObject
    def to_hash
        {}
    end
end

obj = AA.new

def func(**hash)
    puts hash
end

func **obj          # <- error on this line

run ok in MRI,but jruby report error :

NoMethodError: undefined method `respond_to?' for #<AA:0x282003e1>
  <main> at test.rb:13
    load at org/jruby/RubyKernel.java:974
  <main> at -e:1

i found jruby call respond_to? :to_hash before call to_hash,but MRI not.

ENV

jruby 9.1.5.0 (2.3.1) 2016-09-23 fffffff Java HotSpot(TM) Client VM 25.101-b13 on 1.8.0_101-b13 +jit [mswin32-x86]

@headius headius added this to the JRuby 9.1.6.0 milestone Oct 7, 2016

@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 7, 2016

It looks like we're doing 1.8 conversion logic for this case (and several others) rather than 1.9+ "checked" conversion logic. I have a fix coming that should solve this and prevent other reports down the line (by making the old 1.8 methods just call 1.9 logic).

@headius headius closed this in d97bf85 Oct 7, 2016

headius added a commit that referenced this issue Oct 7, 2016

etehtsea added a commit to etehtsea/jruby that referenced this issue Oct 10, 2016

Make all 1.8-era convert methods do 1.9 logic.
The 1.8 methods all blindly call respond_to? which breaks on any
BasicObject-based targets as in jruby#4210. This patch modifies the
remaining 1.8 methods in TypeConverter to just call the 1.9 logic,
since there are no cases where MRI blindly calls respond_to? for
implicit conversions anymore.

Fixes jruby#4210.

etehtsea added a commit to etehtsea/jruby that referenced this issue Oct 10, 2016

eregon added a commit to ruby/spec that referenced this issue Oct 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment