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

Hash#select! inconsistency with MRI when yielding only one argument #3137

Closed
robin850 opened this issue Jul 15, 2015 · 6 comments
Closed

Hash#select! inconsistency with MRI when yielding only one argument #3137

robin850 opened this issue Jul 15, 2015 · 6 comments

Comments

@robin850
Copy link
Contributor

Hello,

There's a tiny behavioral difference between MRI and JRuby regarding the Hash#select! method when there's only one argument passed to the method's block:

>> h = {a: :b}

>> RUBY_ENGINE
=> "ruby"
>> h.select! { |k| p k }
:a

>> RUBY_ENGINE
=> "jruby"
>> h.select! { |k| p k }
[:a, :b]

The problem seems to be in keep_ifCommon ; I tried to write a fix but I haven't been able to.

Have a nice day!

@kares
Copy link
Member

kares commented Jul 15, 2015

you mean JRuby 1.7.x right? ... there's been a similar issue with take_while

@robin850
Copy link
Contributor Author

@kares : Actually I did not test with 1.7, just with JRuby 9000

@kares
Copy link
Member

kares commented Jul 15, 2015

quick test - 1.7.x behaves fine (compatibly with MRI 1.9.3) thus marking as 9K :

jruby-1.7.20 :001 > h = {a: :b}
 => {:a=>:b} 
jruby-1.7.20 :002 > h.select! { |k| p k }
:a

@enebo enebo added this to the JRuby 9.0.1.0 milestone Jul 15, 2015
@enebo
Copy link
Member

enebo commented Jul 15, 2015

This one is non-trivial to fix atm but it is pretty important so we will target this (along with several other block parameter bugs for first point release after release.

@enebo enebo modified the milestones: JRuby 9.0.1.0, JRuby 9.0.2.0 Sep 2, 2015
@enebo enebo closed this as completed in 303a128 Oct 14, 2015
@enebo
Copy link
Member

enebo commented Oct 14, 2015

yieldSpecific with two args to a proc which receives one arg is broken atm but I changed these all to yieldArray. I would try and fix yieldSpecific but we have a much larger task for blocks and it will get handled then.

@robin850
Copy link
Contributor Author

Thanks for fixing this !

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

No branches or pull requests

3 participants