This project is closed and read-only.
Backport #5234 closed
`unexpected return' occurs when a proc is called in ensure
Added by ko1 (Koichi Sasada) about 15 years ago.
Updated over 10 years ago.
Description
Similar as Bug #2729 , `unexpected return' occurs when a proc is called in ensure. I'm not sure why it doesn't fix with Bug #2729 .
test code¶
class C
def each
begin
yield :foo
ensure
Proc.new
end
end
def detect
each{|e|
r = yield(e)
return true if r
}
false
end
end
p C.new.detect{|e|
true
}
The cause is Proc.new doesn't rewrite errinfo.
A following patch fixes this problem.
I'll commit it to trunk/ruby_1_9_3 later.
https://gist.github.com/1175062
Status changed from Open to Closed
% Done changed from 0 to 100
This issue was solved with changeset r33096.
Koichi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
[Bug #5234] [ruby-core:39125]
This code will be removed after changing throw mechanism (see r33064).
vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.
vm.c (vm_make_env_each): changed accordingly.
vm_core.h: ditto.
bootstraptest/test_flow.rb: add tests for above.
Same issue occurs on 1.9.2-p290. Can this be backported to it as well?
Thanks.
Tracker changed from Bug to Backport
Status changed from Closed to Assigned
Assignee changed from ko1 (Koichi Sasada) to yugui (Yuki Sonoda)
Yugui-san:
Could you consider backporting the fix?
Target version changed from 1.9.3 to 1.9.2
Project changed from Ruby to 12
Category changed from core to core
Target version deleted (1.9.2 )
Status changed from Assigned to Rejected
Also available in: PDF
Atom