ruby-changes:4842
From: ko1@a...
Date: Fri, 9 May 2008 00:55:04 +0900 (JST)
Subject: [ruby-changes:4842] matz - Ruby:r16336 (trunk): * parse.y (arg): operator assignment "a += b rescue c" should be
matz 2008-05-09 00:54:32 +0900 (Fri, 09 May 2008) New Revision: 16336 Modified files: trunk/ChangeLog trunk/lib/csv.rb trunk/parse.y trunk/version.h Log: * parse.y (arg): operator assignment "a += b rescue c" should be parsed as "a += (b rescue c)" just like normal assignment. [ruby-talk:301000] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=16336&r2=16335&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=16336&r2=16335&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16336&r2=16335&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/csv.rb?r1=16336&r2=16335&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 16335) +++ ChangeLog (revision 16336) @@ -1,3 +1,9 @@ +Fri May 9 00:03:50 2008 Yukihiro Matsumoto <matz@r...> + + * parse.y (arg): operator assignment "a += b rescue c" should be + parsed as "a += (b rescue c)" just like normal assignment. + [ruby-talk:301000] + Thu May 8 18:14:00 2008 Yukihiro Matsumoto <matz@r...> * bignum.c (rb_big_and): bit-wise operation should not take float Index: lib/csv.rb =================================================================== --- lib/csv.rb (revision 16335) +++ lib/csv.rb (revision 16336) @@ -1524,7 +1524,7 @@ # loop do # add another read to the line - line += @io.gets(@row_sep) rescue return nil + (line += @io.gets(@row_sep)) rescue return nil # copy the line so we can chop it up in parsing parse = line.dup parse.sub!(@parsers[:line_end], "") Index: parse.y =================================================================== --- parse.y (revision 16335) +++ parse.y (revision 16336) @@ -1792,9 +1792,11 @@ | 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 @@ $$ = 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 { /*%%%*/ Index: version.h =================================================================== --- version.h (revision 16335) +++ version.h (revision 16336) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-05-08" +#define RUBY_RELEASE_DATE "2008-05-09" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080508 +#define RUBY_RELEASE_CODE 20080509 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 8 +#define RUBY_RELEASE_DAY 9 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/