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

**operator behavior is different from MRI #4210

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

**operator behavior is different from MRI #4210

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

Comments

@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
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 as completed in d97bf85 Oct 7, 2016
etehtsea pushed a commit to etehtsea/jruby that referenced this issue Oct 10, 2016
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 pushed a commit to etehtsea/jruby that referenced this issue Oct 10, 2016
eregon pushed 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
Projects
None yet
Development

No branches or pull requests

2 participants