Issue #8239 has been updated by dunric (David Unric).


nobu (Nobuyoshi Nakada) wrote:
> =begin
> Not only this case, some assignments can't include (({rescue})) modifier, e.g.:
> 
>   x = 1
>   x += raise rescue 2
> 
> makes ((|x|)) (({3})), while
> 
>   x = [1]
>   x[0] += raise rescue 2
> 
> doesn't change ((|x|)).
> 
> It would be possible to make them consistent all, but obviously causes
> an incompatibility.
> 
> =end

I can confirm this behaviour. This is another example parsing of expression with inline rescue is broken.

I would like to see at least _one_ real world example relying on this inconsistent behaviour. I don't expect fixing this bug would cause any incompatibility. Prove me wrong.


----------------------------------------
Bug #8239: Inline rescue bug
https://bugs.ruby-lang.org/issues/8239#change-38411

Author: dunric (David Unric)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: syntax
Target version: 
ruby -v: 2.0.0p0


There is a possible bug in parsing of inline rescue.
When an inline rescue is a part of multiple assignment and exception is raised, the assignment is silently ignored.

def foo
  raise "error"
end

bar, baz = 1,2    # bar == 1, baz == 2
bar, baz = foo rescue [3,4] # no assignment performed:       bar == 1, baz == 2
                            # expected after the expression: bar == 3, baz == 4

Already discussed at stackoverflow.com:
http://stackoverflow.com/questions/15880136/exceptions-why-does-adding-parenthesis-change-anything


-- 
http://bugs.ruby-lang.org/