[Ironruby-core] MRI 1.8.6 bug - exit is ignored if ensure clause throws exception which is caught by outer rescue

Tomas Matousek Tomas.Matousek at microsoft.com
Mon Jan 12 16:33:03 EST 2009


I believe this is by design. Exit throws an exception (SystemExit). The exception is not rescued by a default rescue clause because it doesn't derive from StandardError. Thus the raise in ensure gets called and it raises RuntimeError which gets caught in the outer rescue because RuntimeError <: StandardError.

Tomas

From: Shri Borde [mailto:Shri.Borde at microsoft.com]
Sent: Monday, January 12, 2009 12:32 PM
To: ironruby-core at rubyforge.org; ruby-core at ruby-lang.org
Subject: [ruby-core:21289] MRI 1.8.6 bug - exit is ignored if ensure clause throws exception which is caught by outer rescue

The following code snippet does print "after foo" when using MRI 1.8.6 on Windows Vista, showing that exit is ignored. Any thoughts on whether this is by design, a known bug, or a new issue? If it's the latter, should I open a bug for it?

def foo
  begin
    begin
      begin
        exit
      rescue
        puts "We never reach here"
      end
    ensure
      raise "exception from ensure"
    end
  rescue
    puts "We do reach here, which is unexpected"
  end
end

foo
print "after foo"

Thanks,
Shri

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090112/eec33e3d/attachment.html>


More information about the Ironruby-core mailing list