Project

General

Profile

Actions

Backport #5234

closed

`unexpected return' occurs when a proc is called in ensure

Added by ko1 (Koichi Sasada) over 13 years ago. Updated over 8 years ago.

Status:
Rejected
[ruby-core:39125]

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
}

Updated by ktsj (Kazuki Tsujimoto) over 13 years ago

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

Actions #2

Updated by ktsj (Kazuki Tsujimoto) over 13 years ago

  • 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.

Updated by andhapp (Anuj Dutta) over 13 years ago

Same issue occurs on 1.9.2-p290. Can this be backported to it as well?

Thanks.

Actions #4

Updated by ktsj (Kazuki Tsujimoto) over 13 years ago

  • 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?

Updated by ktsj (Kazuki Tsujimoto) over 13 years ago

  • Target version changed from 1.9.3 to 1.9.2
Actions #6

Updated by kosaki (Motohiro KOSAKI) over 13 years ago

  • Project changed from Ruby master to Backport192
  • Category changed from core to core
  • Target version deleted (1.9.2)
Actions #7

Updated by naruse (Yui NARUSE) over 8 years ago

  • Status changed from Assigned to Rejected
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0