[BUG?] Fun with aliases

F

Florian Gross

Moin!

Just thought I'd mention this:

C:\>ruby
alias $! $foo; $foo = 5; begin; raise "foo"; rescue => err; p err; end
^D
5

However:

C:\>ruby
alias $! $foo; $foo = 5; begin; raise "foo"; rescue Fixnum => err; p
err; end
^D
-:1: foo (RuntimeError)

I'm using ruby 1.8.1 (2003-12-25) [i386-mswin32] and I'm able to
reproduce the same behavior with ruby 1.8.0 (2003-08-04) [i686-linux-gnu].

Which means Ruby still knowns which exception was really raised, but
misrepresents it in case you're rescuing it to a variable.

I couldn't produce any crashes or other weird things by aliasing any
other global variables, by the way.

Regards,
Florian Gross
 
Y

Yukihiro Matsumoto

Hi,

In message "[BUG?] Fun with aliases"

|Just thought I'd mention this:
|
|C:\>ruby
|alias $! $foo; $foo = 5; begin; raise "foo"; rescue => err; p err; end
|^D
|5

Don't use variable aliasing, especially to replace special variable. ;-)
I will fix this soon anyway.

matz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,301
Latest member
BuyPureganics

Latest Threads

Top