Project

General

Profile

Actions

Feature #12041

open

Change the initializer of NameError to take a receiver as the third argument

Added by yuki24 (Yuki Nishijima) almost 9 years ago. Updated almost 9 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:73628]

Description

I would like to change NameError#initialize to take a receiver object as the third argument. An example would be like this:

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. 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0