Actions
Bug #7170
closedtOP_ASGN and rescue_modifier precedence, with a few confusing examples
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-10-12 trunk 37163) [x86_64-darwin12.2.0]
Backport:
Description
parse.y shows that tOP_ASGN has precedence over modifier_rescue.
So I expect that
a = 1
a += [] rescue 5
should be parsed as "(a += []) rescue 5". Furthermore, it should evaluate to 5, and leave a untouched.
But in reality, this raises a TypeError. (If you rescue this TypeError, you can see that a is untouched.)
Likewise,
a = 'a'
a += b rescue 'c'
should not raise a NameError (for b), evaluate to 'c', and leave 'a' untouched.
However, in reality, this does not raise any exception, but it evaluates to 'ac' and assigns the value 'ac' to a.
Did I reason this incorrectly? Or is there a bug somewhere?
Actions
Like0
Like0Like0