**operator behavior is different from MRI #4210

Closed
personnel opened this Issue Oct 6, 2016 · 1 comment

Projects

None yet

2 participants

@personnel
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
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 added a commit that referenced this issue Oct 7, 2016
@headius headius 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 #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 #4210.
d97bf85
@headius headius added a commit that closed this issue Oct 7, 2016
@headius headius 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 #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 #4210.
d97bf85
@headius headius closed this in d97bf85 Oct 7, 2016
@etehtsea etehtsea added a commit to etehtsea/jruby that referenced this issue Oct 10, 2016
@headius @etehtsea headius + etehtsea 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 #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 #4210.
627056e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment