1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2008-05-08 15:54:32 +00:00
parent 65b55c26a1
commit 2acb400eb1
4 changed files with 45 additions and 6 deletions

View file

@ -1,3 +1,9 @@
Fri May 9 00:03:50 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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@ruby-lang.org>
* bignum.c (rb_big_and): bit-wise operation should not take float

View file

@ -1524,7 +1524,7 @@ class CSV
#
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], "")

37
parse.y
View file

@ -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
{
/*%%%*/

View file

@ -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[];