-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix Kernel#warn override #2911
Fix Kernel#warn override #2911
Conversation
Hi @jeremyevans! Thanks for the fix. I added a second commit that should fix the failing test (coming from #2442 for context) and a regression test for your fix. What do you think? |
mmmm. Ruby-head build is failing 👉 https://travis-ci.org/rubygems/rubygems/jobs/584028540. That's using a ruby from a week ago (ruby 2.7.0dev (2019-09-05T13:16:21Z trunk 433c9c0) [x86_64-linux]) But it's passing for me locally against a more recent version (ruby 2.7.0dev (2019-09-09T12:27:40Z master 89c5d5a) [x86_64-linux]). Has something change in the last week regarding this? 🤔. |
@deivid-rodriguez Thanks for working on the regression test, this looks good to me. I think your approach when uplevel is provided is better. My approach had a bug where the new uplevel would be overridden by the originally provided one. JRuby 9.2 treats an empty keyword hash as uplevel 0 instead of no uplevel, which I'm guessing is the reason that you aren't sending keywords on JRuby in the first call. That seems like a bug in JRuby, I'll report it upstream. |
Nice @jeremyevans! Yeah, there was one failing test on jruby, so I figured we should keep the implementation unchanged on jruby for now. Even if it's currently buggy, at least don't make it worse. I subscribed to your jruby issue so I remember to remove the conditional once they fix this. What about the |
ruby-head no longer sends an empty hash to C functions (or Ruby methods that do not accept keywords) if using an empty keyword splat when calling the method. |
80d3487
to
288f462
Compare
I rebased this PR, precisely to check how it is doing against ruby-head (since it was passing for me locally against ruby 2.7.0dev (2019-09-09T12:27:40Z master 89c5d5a), and our CI no longer depends on TravisCI upgrading its ruby-head installation. But CI doesn't seem to have been triggered. @hbst Any ideas? |
This makes the Kernel#warn override behave the same as the default Kernel#warn. Previously, behavior could be different, because an empty hash or empty keyword arguments would be swallowed by the override, and the second to last argument could be treated as the keyword argument by the default Kernel#warn. For example: warn({x:1}, {y:2}, {}) # C version outputs: {:x=>1} {:y=>2} # Rubygems version raises: unknown keyword: y (ArgumentError) By using a keyword splat, and passing the keyword splat to the default version, we can make behavior the same.
And test the fix we're adding.
288f462
to
cc255b7
Compare
Umm, We couldn't care the ruby-head version on Travis. If we hope to test the latest head version, We can use https://github.com/ruby/ruby-docker-images with GitHub Actions. I try to switch it from RVM later. |
@bundlerbot r+ |
2911: Fix Kernel#warn override r=hsbt a=jeremyevans # Description: This makes the Kernel#warn override behave the same as the default Kernel#warn. Previously, behavior could be different, because an empty hash or empty keyword arguments would be swallowed by the override, and the second to last argument could be treated as the keyword argument by the default Kernel#warn. For example: warn({x:1}, {y:2}, {}) # C version outputs: {:x=>1} {:y=>2} # Rubygems version raises: unknown keyword: y (ArgumentError) By using a keyword splat, and passing the keyword splat to the default version, we can make behavior the same. This issue was originally reported on the Ruby bug tracker: https://bugs.ruby-lang.org/issues/16157#note-8 # Tasks: - [X] Describe the problem / feature - [ ] Write tests - [X] Write code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: Jeremy Evans <code@jeremyevans.net> Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
Build succeeded |
2931: Pick missing changes at #2911 r=hsbt a=hsbt # Description: @jeremyevans This is the missing commit at #2911 from ruby/ruby@80b5a0f ______________ # Tasks: - [ ] Describe the problem / feature - [ ] Write tests - [ ] Write code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
2931: Pick missing changes at #2911 r=hsbt a=hsbt # Description: @jeremyevans This is the missing commit at #2911 from ruby/ruby@80b5a0f ______________ # Tasks: - [ ] Describe the problem / feature - [ ] Write tests - [ ] Write code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
Description:
This makes the Kernel#warn override behave the same as the default
Kernel#warn. Previously, behavior could be different, because an
empty hash or empty keyword arguments would be swallowed by the
override, and the second to last argument could be treated as the
keyword argument by the default Kernel#warn.
For example:
By using a keyword splat, and passing the keyword splat to the
default version, we can make behavior the same.
This issue was originally reported on the Ruby bug tracker:
https://bugs.ruby-lang.org/issues/16157#note-8
Tasks:
I will abide by the code of conduct.