Bug #1887: nil exception can be thrown
http://redmine.ruby-lang.org/issues/show/1887

Author: Tomas Matousek
Status: Open, Priority: Normal
ruby -v: ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]

This code throws nil exception object by assigning nil to $!:

module Any
  def self.===(other)
    puts "#{self.inspect} === #{other.inspect}"
    true
  end
end

begin
  begin
    raise Exception.new
  rescue ($!=nil; Exception)
  end

  puts 'after'
rescue Any
  puts "rescue: #{$!.inspect}"
end

The output is:
Any === nil
rescue: nil

Expected behavior: 
If $! is set to nil it is not rethrown.


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