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

* parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch

statement, and call rb_bug() if an unknown type is passed to
  negate_lit(). [ruby-core:56316] [Bug #8717]

* bootstraptest/test_literal_suffix.rb (assert_equal): add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
charliesome 2013-08-02 01:40:27 +00:00
parent 3f109150e0
commit 29c5a3b89c
3 changed files with 15 additions and 0 deletions

View file

@ -1,3 +1,11 @@
Fri Aug 2 10:39:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
* parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch
statement, and call rb_bug() if an unknown type is passed to
negate_lit(). [ruby-core:56316] [Bug #8717]
* bootstraptest/test_literal_suffix.rb (assert_equal): add test
Fri Aug 2 09:14:47 2013 Eric Hodel <drbrain@segment7.net>
* doc/syntax/refinements.rdoc: Improve description of where you may

View file

@ -3,6 +3,8 @@ assert_equal '0/1', '0r'
assert_equal 'Rational', '0r.class'
assert_equal '1/1', '1r'
assert_equal 'Rational', '1r.class'
assert_equal '-1/1', '-1r'
assert_equal 'Rational', '(-1r).class'
assert_equal '1/1', '0x1r'
assert_equal 'Rational', '0x1r.class'
assert_equal '1/1', '0b1r'
@ -15,6 +17,8 @@ assert_equal '1/1', '01r'
assert_equal 'Rational', '01r.class'
assert_equal '6/5', '1.2r'
assert_equal 'Rational', '1.2r.class'
assert_equal '-6/5', '-1.2r'
assert_equal 'Rational', '(-1.2r).class'
assert_equal '0+0i', '0i'
assert_equal 'Complex', '0i.class'
assert_equal '0+1i', '1i'

View file

@ -9402,6 +9402,8 @@ negate_lit(NODE *node)
node->nd_lit = LONG2FIX(-FIX2LONG(node->nd_lit));
break;
case T_BIGNUM:
case T_RATIONAL:
case T_COMPLEX:
node->nd_lit = rb_funcall(node->nd_lit,tUMINUS,0,0);
break;
case T_FLOAT:
@ -9417,6 +9419,7 @@ negate_lit(NODE *node)
#endif
break;
default:
rb_bug("unknown literal type passed to negate_lit");
break;
}
return node;