summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-12-01 00:03:54 +0000
committerPaul Phillips <paulp@improving.org>2009-12-01 00:03:54 +0000
commit43c13143331d00ea78369ce41caa29e46752a69d (patch)
tree6bd93eb95439e1446c029247a3358d44a1c17acb
parent9fe1f1503ffb3f4c83cbf61459e7021e1780907e (diff)
downloadscala-43c13143331d00ea78369ce41caa29e46752a69d.tar.gz
scala-43c13143331d00ea78369ce41caa29e46752a69d.tar.bz2
scala-43c13143331d00ea78369ce41caa29e46752a69d.zip
Fix and test case for #2378.
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala3
-rw-r--r--test/files/run/bug2378.scala9
2 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index ccb46c0500..3e4400586f 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1167,7 +1167,8 @@ self =>
atPos(in.offset) {
val name = unaryOp()
in.token match {
- case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => literal(true)
+ // Don't include double and float here else we lose -0.0
+ case INTLIT | LONGLIT => literal(true)
case _ => Select(stripParens(simpleExpr()), name)
}
}
diff --git a/test/files/run/bug2378.scala b/test/files/run/bug2378.scala
new file mode 100644
index 0000000000..f696a78b4c
--- /dev/null
+++ b/test/files/run/bug2378.scala
@@ -0,0 +1,9 @@
+object Test
+{
+ val f1 = -0.0
+ val f2 = -(0.0)
+ def main(args: Array[String]): Unit = {
+ assert(f1.toString startsWith "-")
+ assert(f2.toString startsWith "-")
+ }
+}