Issue #12041 has been updated by Nobuyoshi Nakada.


I found this causes `drb` test failures, since `NoMethodError` now refers `DRbObject` and `Marshal.dump` fails.

----------------------------------------
Feature #12041: Change the initializer of NameError to take a receiver as the third argument
https://bugs.ruby-lang.org/issues/12041#change-56959

* Author: Yuki Nishijima
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
I would like to change `NameError#initialize` to take a receiver object as the third argument. An example would be like this:

```ruby
receiver_object = Object.new
name_error      = NameError.new("Error message", "name", receiver_object)

name_error.receiver.equal?(receiver_object) # => true
```

The reason I wanted this change is Rails overrides `Module#const_missing` and [raises an NameError without a receiver object](https://github.com/rails/rails/blob/23b6f65/activesupport/lib/active_support/dependencies.rb#L567-L569). It has actually affected one of the did_you_mean's spell checkers and thus no suggestions for constant names will be made on Rails. One more use case I can think of is when there's a class that inherits from `NameError` or `NoMethodError` and an arbitrary receiver needs to be passed to the initializer of the class.

Please let me know if you have any thoughts.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>