It seems that OP_JMPUW does not call the ensure block when a is pointing to the beginning of the begin block.
For example:
for _ in [1]
begin
puts 1
redo
ensure
puts 2
break
end
end
Ruby 3.3 will print:
mruby (master) is indefinitly printing 1.
This probably happens because OP_JMPUW is pointing to puts 1, so it interprets it as jumping before puts 1 and after the begin keyword. However, it should jump before puts 1 to outside of the begin block and call the ensure block.
https://github.com/mruby/mruby/blob/3505874f72fb6e7f78cba6f3d7cf9d587349667c/src/vm.c#L1724C11-L1724C109
If I understand correctly, the condition should be changed from:
a < mrb_irep_catch_handler_unpack(ch->begin)
to:
a <= mrb_irep_catch_handler_unpack(ch->begin)
It seems that
OP_JMPUWdoes not call the ensure block whenais pointing to the beginning of thebeginblock.For example:
Ruby 3.3 will print:
mruby (master) is indefinitly printing
1.This probably happens because
OP_JMPUWis pointing toputs 1, so it interprets it as jumping beforeputs 1and after thebeginkeyword. However, it should jump beforeputs 1to outside of thebeginblock and call the ensure block.https://github.com/mruby/mruby/blob/3505874f72fb6e7f78cba6f3d7cf9d587349667c/src/vm.c#L1724C11-L1724C109
If I understand correctly, the condition should be changed from:
to: