From: matz@... (Yukihiro Matsumoto) Date: 2002-12-25T08:38:14+09:00 Subject: Re: rescue statement modifier behavior change in 1.8.0 Hi, In message "rescue statement modifier behavior change in 1.8.0" on 02/12/25, "Tim Hunter" writes: |So I'm spending my Christmas Eve trying out new versions of Ruby. What a |Christmas present! | |The following program works without error in 1.6.8. With the |1.8.0preview1, the rescue statement modifier doesn't catch the IndexError. |The program terminates with the message: | |[tim:~]$ ruby foo.rb |foo.rb:4:in `bar=': bar too big (IndexError) | from foo.rb:16 | |Is this a deliberate change in behavior? Yes. |Here's the program: | |class Foo | def bar=(b) | if b > 10 | raise IndexError, "bar too big" | end | end |end | |foo = Foo.new |begin | foo.bar = 11 |rescue | foo.bar=10 |end | |foo.bar = 11 rescue 10 |exit foo.bar = 11 rescue 10 line was parsed as (foo.bar = 11) rescue 10 or begin foo.bar = 11 rescue 10 end on 1.6.x. On 1.8.0, it is parsed as foo.bar = (11 rescue 10) Put extra parenthesises, if you want the old behavior. matz.