Hi all,

I have a question about the method OptionParser#notwice in 
lib/optparse.rb, line 988:

  def notwice(obj, prv, msg)
    unless !prv or prv == obj
      begin
        raise ArgumentError, "argument #{msg} given twice: #{obj}"
      rescue
        $@[0, 2] = nil
        raise
      end
    end
    obj
  end

The line that is bugging me is '$@[0,2] = nil'. It leads to an invalid 
backtrace, backtraces are not supposed to contain nil.

(1) Shouldn't this line rather be '$@.unshift(2)' instead?

(2) The runtime behavior of 'raise' in the line thereafter seems 
particularly weird to me. It does not really raise anything. In fact, it 
just terminates the program, executing ensure clauses only. Please have 
a look at the following example:

  begin
    begin
      raise ArgumentError
    rescue
      $@[0,2] = nil
      raise
    ensure
      puts 'inner ensure'
    end
   
    puts 'after inner ensure'
   
  rescue
    puts 'outer rescue'
  ensure
    puts 'outer ensure'
  end
 
  puts 'after outer ensure'
   
If you run it, you will get the following output:

  inner ensure
  outer ensure

Nothing else (tested with current trunk). This can't be the right 
result, can it?

Best regards,
Tilman