Implement KeyError#receiver and KeyError#key#4940
Merged
enebo merged 2 commits intojruby:ruby-2.5from Jan 5, 2018
Merged
Conversation
enebo
requested changes
Jan 5, 2018
Member
enebo
left a comment
There was a problem hiding this comment.
Just make that one change and this looks great.
|
|
||
| public RubyKeyError(Ruby runtime, RubyClass exceptionClass, String message, IRubyObject recv, IRubyObject key) { | ||
| super(runtime, exceptionClass, message); | ||
| this.receiver = recv == null ? runtime.getNil() : recv; |
Member
There was a problem hiding this comment.
Can you remove the null checks and above just pass in nil in the constructor above? I think we can accept the contract for this internal type can guarantee non-null values. In Array#fetch (and this is good to know) and all @JRubyMethods no passed in arguments will ever be null. We eliminate a lot of bulletproofing this way.
Contributor
Author
There was a problem hiding this comment.
Good observation, thanks. I believe I addressed your recommendation in the new commits I just pushed. Please let me know if there is something else to improve.
For more information, please see feature #12063.
9346eff to
0cf8356
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
This is another feature targeting Ruby 2.5 [1]: KeyError#receiver and KeyError#key (feature #12063).
Note: the tests are copied from MRI.
To implement this I followed the approach used with NameError class, since it has a similar behaviour. If this is not the right approach, just let me know.
Thanks for your review and feedback.