Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rubinius 1.0 returns NameError instead of NoMethodError. #293

Closed
postmodern opened this Issue · 4 comments

3 participants

Postmodern Ivan Samsonov Evan Phoenix
Postmodern

I just noticed that calls to non-existant methods result in NameError exceptions, instead of NoMethodError exceptions. This behavior seems to differ from how MRI and JRuby handle non-existant methods.

Postmodern

Ah, it appears the error actually occurs when one invokes a non-existant-method with parenthesis or a block.

A test script:

begin
  blah()
rescue NoMethodError
  puts "Ruby properly raised a NoMethodError for blah()"
end

begin
  blah { }
rescue NoMethodError
  puts "Ruby properly raised a NoMethodError for blah { }"
end

On Ruby 1.8.7:

Ruby properly raised a NoMethodError for blah()
Ruby properly raised a NoMethodError for blah { }

On Ruby 1.9.1:

Ruby properly raised a NoMethodError for blah()
Ruby properly raised a NoMethodError for blah { }

On JRuby:

Ruby properly raised a NoMethodError for blah()
Ruby properly raised a NoMethodError for blah { }
Postmodern

An improved script, which distinguishes the difference between NoMethodError and NameError:

begin
  blah()
rescue NoMethodError
  puts "Ruby properly raised a NoMethodError for blah()"
rescue NameError
  puts "Ruby instead raised a NameError for blah()"
end

begin
  blah { }
rescue NoMethodError
  puts "Ruby properly raised a NoMethodError for blah { }"
rescue NameError
  puts "Ruby instead raised a NameError for blah { }"
end

On Rubinius 1.0:

$ rvm use rbx-head
Using rbx head
$ ruby test_no_method.rb 
Ruby instead raised a NameError for blah()
Ruby instead raised a NameError for blah { }
Ivan Samsonov
Collaborator
kronos:rubinius kronos$ ruby x.rb
Ruby properly raised a NoMethodError for blah()
Ruby properly raised a NoMethodError for blah { }
kronos:rubinius kronos$ bin/rbx x.rb
Ruby instead raised a NameError for blah()
Ruby instead raised a NameError for blah { }
Evan Phoenix
Owner

Disambiguate a vcall send to the send_method opcode. Closed by b4ad0af.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.