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

Projects

None yet

4 participants

@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
Member
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 from chunk_when not returning results equivalent to ruby 2.4 (jruby 9.1.6.0) to chunk_when not returning results equivalent to MRI ruby 2.3+ (jruby 9.1.6.0) Dec 28, 2016
@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 olbrich referenced this issue in olbrich/ruby-units Dec 29, 2016
Merged

Ruby 2.4.0 #148

@olbrich olbrich added a commit to olbrich/ruby-units that referenced this issue Dec 30, 2016
@olbrich olbrich workaround for jruby bug (see jruby/jruby#4410) 90bb721
@olbrich olbrich added a commit to olbrich/ruby-units that referenced this issue Dec 30, 2016
@olbrich olbrich Ruby 2.4.0 (#148)
* 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)
8c4821a
@headius headius changed the title from chunk_when not returning results equivalent to MRI ruby 2.3+ (jruby 9.1.6.0) to chunk_while not returning results equivalent to MRI ruby 2.3+ (jruby 9.1.6.0) Jan 5, 2017
@headius
Member
headius commented Jan 5, 2017

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

@cthulhua
Contributor
cthulhua commented Jan 5, 2017

Yep, I'll take a look at this

@headius
Member
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
Contributor
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
Member
headius commented Jan 6, 2017

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

@headius headius closed this in b003233 Jan 6, 2017
@headius headius added this to the JRuby 9.1.7.0 milestone Jan 6, 2017
@headius
Member
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