diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-08 15:54:32 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-08 15:54:32 +0000 |
commit | 2acb400eb1fdda72608a0d9fa59382666af84026 (patch) | |
tree | 3ed29863ffb47062423ccab22d9714b3b65b30d4 /parse.y | |
parent | 65b55c26a15d1b7bf3387e7f31a44f0a669431d0 (diff) |
* parse.y (arg): operator assignment "a += b rescue c" should be
parsed as "a += (b rescue c)" just like normal assignment.
[ruby-talk:301000]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -1792,9 +1792,11 @@ arg : lhs '=' arg | lhs '=' arg modifier_rescue arg { /*%%%*/ - $$ = node_assign($1, NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0)); + value_expr($3); + $3 = NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0); + $$ = node_assign($1, $3); /*% - $$ = dispatch2(assign, $1, dispatch2(rescue_mod,$3,$5)); + $$ = dispatch2(assign, $1, dispatch2(rescue_mod, $3, $5)); %*/ } | var_lhs tOP_ASGN arg @@ -1826,6 +1828,37 @@ arg : lhs '=' arg $$ = dispatch3(opassign, $1, $2, $3); %*/ } + | var_lhs tOP_ASGN arg modifier_rescue arg + { + /*%%%*/ + value_expr($3); + $3 = NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0); + if ($1) { + ID vid = $1->nd_vid; + if ($2 == tOROP) { + $1->nd_value = $3; + $$ = NEW_OP_ASGN_OR(gettable(vid), $1); + if (is_asgn_or_id(vid)) { + $$->nd_aid = vid; + } + } + else if ($2 == tANDOP) { + $1->nd_value = $3; + $$ = NEW_OP_ASGN_AND(gettable(vid), $1); + } + else { + $$ = $1; + $$->nd_value = NEW_CALL(gettable(vid), $2, NEW_LIST($3)); + } + } + else { + $$ = NEW_BEGIN(0); + } + /*% + $3 = dispatch2(rescue_mod, $3, $5); + $$ = dispatch3(opassign, $1, $2, $3); + %*/ + } | primary_value '[' opt_call_args rbracket tOP_ASGN arg { /*%%%*/ |