Project

General

Profile

Actions

Bug #1887

closed

nil exception can be thrown

Bug #1887: nil exception can be thrown

Added by tmat (Tomas Matousek) over 16 years ago. Updated almost 15 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
Backport:
[ruby-core:24768]

Description

=begin
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.
=end

Updated by naruse (Yui NARUSE) over 16 years ago Actions #1

  • Status changed from Open to Closed

=begin
$! is a read-only variable now.
=end

Actions

Also available in: PDF Atom