Robert Klemme wrote:
> 2008/10/1 Nit Khair <sentinel.2001 / gmx.com>:
>> Robert Klemme wrote:
>>
>>> This sounds strange because syntax errors should be caught earlier -
>>> unless they stem from an "require" or "load". Can you post a short
>>> example that reproduces the error?
>>

I've tried to make a trivial case.  Variable x is not initialized.

#!/usr/bin/env ruby -w

begin
  @test = x


ensure
  @test.strip
end

The error I get is:

  x.rb:8: warning: instance variable @test not initialized
  x.rb:8: undefined method `strip' for nil:NilClass (NoMethodError)


Now in real life, "@test = " calls a method elsewhere which may call 
other methods. So i am clueless as to where the error actually is.

Now let's comment the ensure word. The new error message is:

  x.rb:4: undefined local variable or method `x' for main:Object 
(NameError)

So this is currently my only solution.
In this particular case, I now add (before the ensure):

   rescue Exception => boom
     $stderr.print boom

and now I get the error. However, in my real curses program, it skips 
the rescue clause and continues to go into the ensure.
-- 
Posted via http://www.ruby-forum.com/.