History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-2526
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Shot
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
JRuby

Break handling discrepancy between JRuby and MRI

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

Time Tracking:
Not Specified

Environment: Ubuntu 8.04, i386, Sun Java 1.6.0_06, JRuby binary from jruby.org
Issue Links:
dependent
 


 Description  « Hide
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]



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Damian Steer - 15/May/08 06:03 PM
Two reductions (I think):
a = []
def m; 2.times { 2.times { yield } }; end
m {a << 1; break}
p a # [1] in MRI, [1,1] in jruby
x = proc { break }; 1.times &x # => LocalJumpError in 
1.times & proc { break } # => 

Damian Steer - 15/May/08 06:06 PM
(Sorry, not sure what happened to previous)
x = proc { break }; 1.times &x # => LocalJumpError in MRI, nothing in jruby
1.times & proc { break } # => LocalJumpError in both