+:x doesn't raise exception

e$B1sF#$H?=$7$^$9!#e(B

Symbol#+@ e$B$de(B Regexp#+@ e$B$,$J$$$N$K0J2<$,Nc30$K$J$i$J$$$N$Oe(B
e$B;EMM$G$7$g$&$+!#e(B

$ ./ruby -ve ‘p(+:x)’
ruby 1.8.6 (2007-07-19 patchlevel 5000) [i686-linux]
:x
$ ./ruby -ve ‘p(+//)’
ruby 1.8.6 (2007-07-19 patchlevel 5000) [i686-linux]
//

e$B=EH"$N6y$G$9$,5$$K$J$C$?$N$G!D!D!#e(B

e$B$J$+$@$G$9!#e(B

At Thu, 19 Jul 2007 22:13:04 +0900,
Yusuke ENDOH wrote in [ruby-dev:31264]:

Symbol#+@ e$B$de(B Regexp#+@ e$B$,$J$$$N$K0J2<$,Nc30$K$J$i$J$$$N$Oe(B
e$B;EMM$G$7$g$&$+!#e(B

e$B%j%F%i%k$NC19!\$OL5;k$7$F$k$s$G$9$,!"%(%i!<$N$[$&$,$$$$$G$7$ge(B e$B$&$+!#$D$$$G$KC19!]$b2DG=$J$iJQ49$9$k$h$&$K$7$F$_$^$7$?$,!#e(B

Index: parse.y

— parse.y (revision 12819)
+++ parse.y (working copy)
@@ -420,4 +420,9 @@ extern int rb_local_defined(ID);
extern int rb_parse_in_eval(void);

+#define numeric_p(val) (\

  • FIXNUM_P(val) || \
  • (!SPECIAL_CONST_P(val) && \
  • (BUILTIN_TYPE(val) == T_FLOAT || BUILTIN_TYPE(val) == T_BIGNUM)))

#else
#define remove_begin(node) (node)
@@ -2007,5 +2012,6 @@ arg : lhs ‘=’ arg
{
/%%%/

  •  if ($2 && nd_type($2) == NODE_LIT) {
    
  •  $$ = 0;
    
  •  if ($2 && nd_type($2) == NODE_LIT && numeric_p($2->nd_lit)) {
         $$ = $2;
     }
    

@@ -2020,5 +2026,10 @@ arg : lhs ‘=’ arg
{
/%%%/

  •  $$ = call_op($2, tUMINUS, 0, 0);
    
  •  if ($2 && nd_type($2) == NODE_LIT && numeric_p($2->nd_lit)) {
    
  •      $$ = negate_lit($2);
    
  •  }
    
  •  else {
    
  •      $$ = call_op($2, tUMINUS, 0, 0);
    
  •  }
       /*%
     $$ = dispatch2(unary, ripper_intern("-@"), $2);
    

@@ -7901,8 +7912,8 @@ negate_lit(NODE *node)
switch (TYPE(node->nd_lit)) {
case T_FIXNUM:

  • node->nd_lit = LONG2FIX(-FIX2LONG(node->nd_lit));
  • node->nd_lit = LONG2NUM(-FIX2LONG(node->nd_lit));
    break;
    case T_BIGNUM:
  • node->nd_lit = rb_funcall(node->nd_lit,tUMINUS,0,0);
  • RBIGNUM(node->nd_lit)->sign = !RBIGNUM(node->nd_lit)->sign;
    break;
    case T_FLOAT:

e$B1sF#$G$9!#e(B

e$B%j%F%i%k$NC19!\$OL5;k$7$F$k$s$G$9$,!"%(%i!<$N$[$&$,$$$$$G$7$ge(B e$B$&$+!#$D$$$G$KC19!]$b2DG=$J$iJQ49$9$k$h$&$K$7$F$_$^$7$?$,!#e(B

e$B$=$N:GE,2=$Oe(B Fixnum#+@
e$B$N:FDj5A$rL5;k$7$F$$$^$9$,$$$$$N$G$7$g$&$+!#e(B

$ ./ruby -ve ‘class Fixnum; def +@; nil; end; end; p(+1)’
ruby 1.8.6 (2007-07-19 patchlevel 5000) [i686-linux]
1

$ ./ruby -ve ‘class Fixnum; def +@; nil; end; end; p(+(1))’
ruby 1.8.6 (2007-07-19 patchlevel 5000) [i686-linux]
nil

e$Be$OL5;k$7$FLdBj$J$5$=$&$J$N$G0l$D$N<j$@$H$O;W$$$^$9$,!"e(B
e$B$=$l$J$ie(B Fixnum#+ e$B$de(B Fixnum#*
e$B$N:FDj5A$bL5;k$7$FDj?t>v$_9~$_e(B
e$B:GE,2=$r<BAu$9$k$H$b$C$H4r$7$=$&$G$9!#e(B

e$B$J$+$@$G$9!#e(B

At Mon, 23 Jul 2007 18:01:14 +0900,
Yusuke ENDOH wrote in [ruby-dev:31282]:

e$B%j%F%i%k$NC19!\$OL5;k$7$F$k$s$G$9$,!"%(%i!<$N$[$&$,$$$$$G$7$ge(B e$B$&$+!#$D$$$G$KC19!]$b2DG=$J$iJQ49$9$k$h$&$K$7$F$_$^$7$?$,!#e(B

e$B$=$N:GE,2=$Oe(B Fixnum#+@ e$B$N:FDj5A$rL5;k$7$F$$$^$9$,$$$$$N$G$7$g$&$+!#e(B

$ ./ruby -ve ‘class Fixnum; def +@; nil; end; end; p(+1)’
ruby 1.8.6 (2007-07-19 patchlevel 5000) [i686-linux]
1

e$B$3$l$Oe(B +1 e$B$G0l$D$N%j%F%i%k$G$9$+$i!"JL$G$9!#3:Ev$9$k$N$Oe(B p(+
1)
e$B$N$h$&$Ke(B+e$B$H?t;z$,J,$+$l$F$$$k>l9g$G$9!#e(B

$ ./ruby -ve ‘class Fixnum; def +@; nil; end; end; p(+(1))’
ruby 1.8.6 (2007-07-19 patchlevel 5000) [i686-linux]
nil

[ruby-dev:31267]e$B$rEv$F$k$H$3$l$be(B1e$B$N$^$^$K$J$j$^$9!#e(B

e$Be$OL5;k$7$FLdBj$J$5$=$&$J$N$G0l$D$N<j$@$H$O;W$$$^$9$,!"e(B
e$B$=$l$J$ie(B Fixnum#+ e$B$de(B Fixnum#* e$B$N:FDj5A$bL5;k$7$FDj?t>v$_9~$_e(B
e$B:GE,2=$r<BAu$9$k$H$b$C$H4r$7$=$&$G$9!#e(B

e$B%j%F%i%kF1;N$N1i;;$O:FDj5A$rL5;k$9$k!"$^$?$O%Q!<%9;~E@$NDj5A$re(B
e$B;H$&$H$+e(B?