summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--bootstraptest/test_literal_suffix.rb4
-rw-r--r--parse.y3
3 files changed, 15 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b41172..cec7b5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/bootstraptest/test_literal_suffix.rb b/bootstraptest/test_literal_suffix.rb
index 29ce8e0..5f86904 100644
--- a/bootstraptest/test_literal_suffix.rb
+++ b/bootstraptest/test_literal_suffix.rb
@@ -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'
diff --git a/parse.y b/parse.y
index 0d11c17..3da3ad0 100644
--- a/parse.y
+++ b/parse.y
@@ -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;