Implement KeyError#receiver and KeyError#key #4940
Merged
Conversation
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; |
enebo
Jan 5, 2018
Member
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.
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.
nomadium
Jan 5, 2018
Author
Contributor
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.
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
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.
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.