berkesokhan / rubydotnetcompiler

Automatically exported from code.google.com/p/rubydotnetcompiler
1 stars 0 forks source link

rescue clause without begin wrongly catches LoadError #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
## Adapted from IronRuby tests (Runtime\Exception\test_rescue_modifier.rb)

def foo
    def f1
        begin
            require "not_existing" 
        rescue 
            puts "not OK f1"
        end
    end
    begin
        f1
    rescue LoadError
        puts "OK f1"
    end

    def f2
        require "not_existing" rescue puts "not OK f2"
    end
    begin
        f2
    rescue LoadError
        puts "OK f2"
    end
end

foo

Expected output:
OK f1
OK f2

Actual output:
OK f1
not OK f2

A "rescue" clause should only catch exceptions that inherit from
StandardError, so therefore f2 is not behaving correctly since LoadError
does not inherit from StandardError. Note that it works fine when there is
also a "begin" clause.

Original issue reported on code.google.com by meaningi...@gmail.com on 4 Oct 2007 at 4:06

GoogleCodeExporter commented 9 years ago

Original comment by meaningi...@gmail.com on 23 Oct 2007 at 5:05