Issue #5234 has been reported by Koichi Sasada.

----------------------------------------
Bug #5234: `unexpected return' occurs when a proc is called in ensure
http://redmine.ruby-lang.org/issues/5234

Author: Koichi Sasada
Status: Open
Priority: Normal
Assignee: Koichi Sasada
Category: core
Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-08-26 revision 33077) [i686-linux]


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
}



-- 
http://redmine.ruby-lang.org