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

chunk_while not returning results equivalent to MRI ruby 2.3+ (jruby 9.1.6.0) #4410

Closed
olbrich opened this issue Dec 25, 2016 · 8 comments
Closed
Labels
Milestone

Comments

@olbrich
Copy link

@olbrich olbrich commented Dec 25, 2016

Environment

$ ruby -v
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.0-b70 on 1.8.0-b132 +jit [darwin-x86_64]
$ uname -a
Darwin Kevins-MacBook-Pro.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

Expected Behavior

$  rvm use ruby-2.4.0
Using ruby-2.4.0
$ irb
2.4.0 :001 > [1].chunk_while { |x| x.even? }.to_a
 => [[1]]

Actual Behavior

$  rvm use jruby-9.1.6.0
Using jruby-9.1.6.0
$ irb
jruby-9.1.6.0 :001 > [1].chunk_while { |x| x.even? }.to_a
 => []
@enebo enebo added the core label Dec 27, 2016
@enebo
Copy link
Member

@enebo enebo commented Dec 27, 2016

Just going to note for anyone who wants to work on this that it is not a 2.4 compat bug but probably a 2.3 one (I did not check earlier). @olbrich I am only mentioning this since 9.1.x of JRuby only supports 2.3 and not 2.4. (9.2.x will support 2.4 specific features). So this is fair game right now if anyone wants to take it on.

@olbrich olbrich changed the title chunk_when not returning results equivalent to ruby 2.4 (jruby 9.1.6.0) chunk_when not returning results equivalent to MRI ruby 2.3+ (jruby 9.1.6.0) Dec 28, 2016
@olbrich
Copy link
Author

@olbrich olbrich commented Dec 28, 2016

@enebo yeah, it probably is inconsistent with all the MRI rubies that support chunk_while (which I think was introduced in ruby 2.3).

olbrich added a commit to olbrich/ruby-units that referenced this issue Dec 30, 2016
olbrich added a commit to olbrich/ruby-units that referenced this issue Dec 30, 2016
* update build tools to check ruby 2.4.0
* clean up usage of some newer methods for compatibility with older ruby versions
* add notes to readme
* ensure we are using jruby that emulates a ruby 2.* series
* workaround for jruby bug (see jruby/jruby#4410)
@headius headius changed the title chunk_when not returning results equivalent to MRI ruby 2.3+ (jruby 9.1.6.0) chunk_while not returning results equivalent to MRI ruby 2.3+ (jruby 9.1.6.0) Jan 5, 2017
@headius
Copy link
Member

@headius headius commented Jan 5, 2017

@cthulhua Hey, feel like taking a stab at this? This was your patch from #3517.

@cthulhua
Copy link
Contributor

@cthulhua cthulhua commented Jan 5, 2017

Yep, I'll take a look at this

@headius
Copy link
Member

@headius headius commented Jan 5, 2017

@cthulhua If it starts to look like it's a problem with JRuby's Enumerable or "native" bits, let us know. We're still dragging along some not-always-correct Java impls of the core Enumerable logic, and these sorts of things are not uncommon to see.

@cthulhua
Copy link
Contributor

@cthulhua cthulhua commented Jan 5, 2017

It's the same issue with #slice_when that was fixed in a8eff5d

Might be worth consolidating the logic

@headius
Copy link
Member

@headius headius commented Jan 6, 2017

@cthulhua Good catch...I'll give that a shot.

@headius headius closed this in b003233 Jan 6, 2017
headius added a commit that referenced this issue Jan 6, 2017
@headius headius added this to the JRuby 9.1.7.0 milestone Jan 6, 2017
@headius
Copy link
Member

@headius headius commented Jan 6, 2017

Ok, I went with @cthulhua's suggestion and combined slice_when and chunk_while logic. This is now fixed.

We may want to look at the Truffle/Rubinius versions of these methods, since we depend on #size being available and they do not.

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.