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

Bug doing coerce with function & #3524

Closed
rbotafogo opened this issue Dec 8, 2015 · 1 comment
Closed

Bug doing coerce with function & #3524

rbotafogo opened this issue Dec 8, 2015 · 1 comment

Comments

@rbotafogo
Copy link

This is a small test that shows different behaviour when coercing + and coercing &. In JRuby 1.7 trying to coerce & raised and exception. I don´t know what is the correct behaviour.

class Test

  def +(val)
    p "doing +"
  end

  def &(val)
    p "doing &"
    2 & val
  end

  def coerce(val)
    p "doing coerce"
    return [Test.new, val]
  end

end

t = Test.new
p 2 & t
p 2 + t
@kares
Copy link
Member

kares commented Apr 9, 2016

verified 1.7.24 behaves exactly as 1.9.3 with that piece of script (let us know if we missed something) :

jruby-1.7.24 :020 > p 2 & t
TypeError: can't convert Test into Integer
    from org/jruby/RubyFixnum.java:1062:in `&'
    from (irb):20:in `evaluate'
    from org/jruby/RubyKernel.java:1079:in `eval'
    from org/jruby/RubyKernel.java:1479:in `loop'
    from org/jruby/RubyKernel.java:1242:in `catch'
    from org/jruby/RubyKernel.java:1242:in `catch'
    from /opt/local/rvm/rubies/jruby-1.7.24/bin/irb:13:in `(root)'
jruby-1.7.24 :021 > p 2 + t
"doing coerce"
"doing +"
"doing +"
 => "doing +" 

@kares kares closed this as completed Apr 9, 2016
@kares kares added this to the Invalid or Duplicate milestone Apr 9, 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