summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-21 08:12:07 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-21 08:12:07 +0000
commit1c770e707762d6737d7f0c297c2fb8b362fa0099 (patch)
treeed0c91c800c00f817124dafb748fcf621501c320 /parse.y
parentff7e65eb845069ab1d865b61e6fe8a989c41c800 (diff)
* parse.y (arg): put back old ** behavior for negative number
right operand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y19
1 files changed, 19 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 723c239..5bbcf06 100644
--- a/parse.y
+++ b/parse.y
@@ -1022,7 +1022,26 @@ arg : lhs '=' arg
}
| arg tPOW arg
{
+ int need_negate = Qfalse;
+
+ if ($1 && nd_type($1) == NODE_LIT) {
+
+ switch (TYPE($1->nd_lit)) {
+ case T_FIXNUM:
+ case T_FLOAT:
+ case T_BIGNUM:
+ if (RTEST(rb_funcall($1->nd_lit,'<',1,INT2FIX(0)))) {
+ $1->nd_lit = rb_funcall($1->nd_lit,rb_intern("-@"),0,0);
+ need_negate = Qtrue;
+ }
+ default:
+ break;
+ }
+ }
$$ = call_op($1, tPOW, 1, $3);
+ if (need_negate) {
+ $$ = call_op($$, tUMINUS, 0, 0);
+ }
}
| tUPLUS arg
{