
| Key: |
JRUBY-2526
|
| Type: |
Bug
|
| Status: |
Open
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Shot
|
| Votes: |
0
|
| Watchers: |
3
|
|
If you were logged in you would be able to see more operations.
|
|
|
JRuby
Created: 15/May/08 04:49 PM
Updated: 16/May/08 06:39 AM
|
|
| Component/s: |
Core Classes/Modules
|
| Affects Version/s: |
JRuby 1.1.1
|
| Fix Version/s: |
None
|
|
|
Environment:
|
Ubuntu 8.04, i386, Sun Java 1.6.0_06, JRuby binary from jruby.org
|
|
Issue Links:
|
dependent
|
|
This issue depends upon:
|
|
JRUBY-2041
Calling the attached method after 6 times returns nil
|
|
|
|
|
|
|
|
Given the below Enumerable extension:
module Enumerable
def every_pair_with_indices
each_with_index do |a, i|
each_with_index do |b, j|
yield [a, b, i, j] if i < j
end
end
end
def every_pair
every_pair_with_indices do |a, b, i, j|
yield [a, b]
end
end
end
when breaking out of Enumerable#every_pair, JRuby 1.1.1 seems to break only out of the final implementation's inner loop, while MRI 1.8.6.p114 breaks out of the whole #every_pair (much like it would break out of #each):
ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux]
>> [1,2,3,4].every_pair{|a,b| p [a,b]; break if [a,b] == [1,3]}
[1, 2]
[1, 3]
=> nil
ruby 1.8.6 (2008-04-22 rev 6555) [i386-jruby1.1.1]
>> [1,2,3,4].every_pair{|a,b| p [a,b]; break if [a,b] == [1,3]}
[1, 2]
[1, 3]
[2, 3]
[2, 4]
[3, 4]
=> [1, 2, 3, 4]
|
|
Description
|
Given the below Enumerable extension:
module Enumerable
def every_pair_with_indices
each_with_index do |a, i|
each_with_index do |b, j|
yield [a, b, i, j] if i < j
end
end
end
def every_pair
every_pair_with_indices do |a, b, i, j|
yield [a, b]
end
end
end
when breaking out of Enumerable#every_pair, JRuby 1.1.1 seems to break only out of the final implementation's inner loop, while MRI 1.8.6.p114 breaks out of the whole #every_pair (much like it would break out of #each):
ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux]
>> [1,2,3,4].every_pair{|a,b| p [a,b]; break if [a,b] == [1,3]}
[1, 2]
[1, 3]
=> nil
ruby 1.8.6 (2008-04-22 rev 6555) [i386-jruby1.1.1]
>> [1,2,3,4].every_pair{|a,b| p [a,b]; break if [a,b] == [1,3]}
[1, 2]
[1, 3]
[2, 3]
[2, 4]
[3, 4]
=> [1, 2, 3, 4] |
Show » |
|
a = [] def m; 2.times { 2.times { yield } }; end m {a << 1; break} p a # [1] in MRI, [1,1] in jrubyx = proc { break }; 1.times &x # => LocalJumpError in 1.times & proc { break } # =>