Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug where NameError#receiver didn't return receiver when it's caused by Struct#[] #3864

Merged
merged 1 commit into from
May 9, 2016
Merged

Fixed a bug where NameError#receiver didn't return receiver when it's caused by Struct#[] #3864

merged 1 commit into from
May 9, 2016

Conversation

yuki24
Copy link
Contributor

@yuki24 yuki24 commented May 9, 2016

When a NameError is raised from Struct#[], the NameError#receiver method should return the receiver object rather than raising ArgumentError: no receiver is available.

Actual:

(Struct.new(:does_exist).new(nil)[:doesnt_exist] rescue $!).receiver
# => ArgumentError: no receiver is available

Expected:

(Struct.new(:does_exist).new(nil)[:doesnt_exist] rescue $!).receiver
# => #<struct does_exist=nil>

When a NameError is raised from Struct#[], the #receiver should return the receiver object rather than raising "ArgumentError: no receiver is available".
@headius
Copy link
Member

headius commented May 9, 2016

Nice, thanks! I will merge this and wire the test up to our suite, but I'll also modify it to use the same sprintf-style NameError logic that the rest of the system uses rather than a custom error method.

@headius headius merged commit 176050c into jruby:master May 9, 2016
@yuki24 yuki24 deleted the fix-nameerror-receiver-coming-from-struct branch May 12, 2016 13:27
@enebo enebo modified the milestone: Non-Release May 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants