Actions
Bug #20917
openredo/next in nested begin block causes wrong order of execution
Bug #20917:
redo/next in nested begin block causes wrong order of execution
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-darwin24]
Description
It seems that redo/next in a nested begin block can cause the wrong order of execution.
For example:
for _ in [0]
puts 0
begin
puts 1
begin
puts 2
redo
ensure
puts 3
end
ensure
puts 4
break
end
end
It prints:
0
1
2
3
4
3
4
=> nil
But I think it should print:
0
1
2
3
4
=> nil
Because execution order should be:
puts 0puts 1puts 2redo- unwind to nested
ensureblock puts 3- unwind to outer
ensureblock puts 4break- end of loop
Interestingly enough, if we add an empty rescue block before any of the ensure blocks, then the execution order is correct.
Actions