Project

General

Profile

Feature #10881

NoMethodError#receiever

Added by yuki24 (Yuki Nishijima) over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:68215]

Description

I would like NoMethodError to have receiver method:

receiver    = "receiver"
exception = receiver.doesnt_exist rescue $!

exception.receiver == receiver # => true

This helps did_you_mean gem implement its features without having native C exceptions, and also makes it easier to add "did you mean?" feature to irb. Let mw know what you think. Thanks!

Updated by matz (Yukihiro Matsumoto) about 5 years ago

Looks OK for me. I am interested in how JRuby/Rubinius guys feel about the proposal.

Matz.

Updated by yuki24 (Yuki Nishijima) about 5 years ago

Thanks Matsumoto-san.

I realized that the last line in the example above is wrong, it has to use #equal? instead of #==:

exception.receiver.equal?(receiver) # => true
#3

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Status changed from Open to Closed

Applied in changeset r50945.


error.c: NameError#receiver

  • error.c (name_err_receiver): add NameError#receiver method. [Feature #10881]

Also available in: Atom PDF