diff --git a/ChangeLog b/ChangeLog index 503d8d8458..a88005024c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,11 @@ -Sun May 1 09:13:23 2005 Nobuyoshi Nakada +Sun May 1 09:15:17 2005 Nobuyoshi Nakada * ruby.c (process_sflag): replace '-' in variable names with '_'. [ruby-dev:26107] + * eval.c (rb_eval), parse.y (arg): reduce fixnum range literal at + parser. fixed: [ruby-dev:26113] + Sat Apr 30 11:59:25 2005 Nobuyoshi Nakada * configure.in (RUBY_FUNC_ATTRIBUTE): check for function attribute. diff --git a/eval.c b/eval.c index 39d184e1c0..b35c98fd00 100644 --- a/eval.c +++ b/eval.c @@ -3226,16 +3226,6 @@ rb_eval(self, n) result = rb_range_new(rb_eval(self, node->nd_beg), rb_eval(self, node->nd_end), nd_type(node) == NODE_DOT3); - if (node->nd_state) break; - if (nd_type(node->nd_beg) == NODE_LIT && FIXNUM_P(node->nd_beg->nd_lit) && - nd_type(node->nd_end) == NODE_LIT && FIXNUM_P(node->nd_end->nd_lit)) - { - nd_set_type(node, NODE_LIT); - node->nd_lit = result; - } - else { - node->nd_state = 1; - } break; case NODE_FLIP2: /* like AWK */ diff --git a/parse.y b/parse.y index 45c3e648e9..94c9abb6af 100644 --- a/parse.y +++ b/parse.y @@ -1760,7 +1760,14 @@ arg : lhs '=' arg /*%%%*/ value_expr($1); value_expr($3); - $$ = NEW_DOT2($1, $3); + if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && + nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qfalse); + $$ = $1; + } + else { + $$ = NEW_DOT2($1, $3); + } /*% $$ = dispatch2(dot2, $1, $3); %*/ @@ -1770,7 +1777,14 @@ arg : lhs '=' arg /*%%%*/ value_expr($1); value_expr($3); - $$ = NEW_DOT3($1, $3); + if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && + nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qtrue); + $$ = $1; + } + else { + $$ = NEW_DOT3($1, $3); + } /*% $$ = dispatch2(dot3, $1, $3); %*/