Skip to content

NameError is thrown by method_missing when using self #872

@andrenpaes

Description

@andrenpaes

The method_missing method is throwing the NameError exception instead of NoMethodError when using self as the message receiver.

Here's an example

class Bug
  def method_missing(meth, *args, &block)
    super
  rescue NoMethodError
    puts "Catched Error!"
    args.first
  end

  def set_bug_type
    self.bug_type = 2
  end
end

Bug.new.bug_type = 1
Bug.new.set_bug_type

The expected output is (that's what I get in MRI 1.9.x):

Catched Error!
Catched Error!

The actual output is:

Catched Error!
NameError: undefined local variable or method `bug_type=' for #<Bug:0x37867b45>
  method_missing at org/jruby/RubyBasicObject.java:1670
  method_missing at app/models/bug.rb:5
    set_bug_type at app/models/bug.rb:12
          (root) at app/models/bug.rb:17

This is happening using both JRuby 1.7.3 and 1.7.4.
The platform is a mac running MacOS X 10.8.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions