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

Implement KeyError#receiver and KeyError#key #4940

Merged
merged 2 commits into from Jan 5, 2018

Conversation

Projects
None yet
2 participants
@nomadium
Contributor

nomadium commented Jan 5, 2018

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.

  1. #4876
@enebo

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;

This comment has been minimized.

@enebo

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.

This comment has been minimized.

@nomadium

nomadium Jan 5, 2018

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.

@enebo enebo added this to the JRuby 9.3.0.0 milestone Jan 5, 2018

@enebo enebo merged commit 0cc6193 into jruby:ruby-2.5 Jan 5, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@nomadium nomadium deleted the nomadium:add-ruby-2.5-methods-to-key-error branch Jan 10, 2018

@enebo enebo modified the milestones: JRuby 9.3.0.0, JRuby 9.2.0.0 Apr 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment