From 6b1654834fdb03ba73d7f9fad7b0735024e0d688 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Thu, 27 Jun 2013 22:09:38 +0200 Subject: SI-7620 Remove floating-point-literals-without-digit-after-dot --- .../scala/tools/nsc/ast/parser/Scanners.scala | 11 ++++----- test/files/neg/ambiguous-float-dots.check | 27 ---------------------- test/files/neg/ambiguous-float-dots.flags | 1 - test/files/neg/ambiguous-float-dots.scala | 14 ----------- test/files/neg/ambiguous-float-dots2.check | 7 ++---- test/files/neg/ambiguous-float-dots2.flags | 1 - test/files/neg/ambiguous-float-dots2.scala | 1 - test/files/pos/t2081.scala | 2 +- 8 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 test/files/neg/ambiguous-float-dots.check delete mode 100644 test/files/neg/ambiguous-float-dots.flags delete mode 100644 test/files/neg/ambiguous-float-dots.scala delete mode 100644 test/files/neg/ambiguous-float-dots2.flags diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 2dca39f7a3..9e9c47f401 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -939,9 +939,8 @@ trait Scanners extends ScannersCommon { } if (value > limit) syntaxError("floating point number too large") - if (isDeprecatedForm) { - deprecationWarning("This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit.") - } + if (isDeprecatedForm) + syntaxError("floating point number is missing digit after dot") if (negated) -value else value } catch { @@ -997,10 +996,8 @@ trait Scanners extends ScannersCommon { val lookahead = lookaheadReader val c = lookahead.getc() - /* As of scala 2.11, it isn't a number unless c here is a digit, so - * settings.future.value excludes the rest of the logic. - */ - if (settings.future && !isDigit(c)) + /* Prohibit 1. */ + if (!isDigit(c)) return setStrVal() val isDefinitelyNumber = (c: @switch) match { diff --git a/test/files/neg/ambiguous-float-dots.check b/test/files/neg/ambiguous-float-dots.check deleted file mode 100644 index cdd2d6fa2a..0000000000 --- a/test/files/neg/ambiguous-float-dots.check +++ /dev/null @@ -1,27 +0,0 @@ -ambiguous-float-dots.scala:2: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - val x0 = 5. - ^ -ambiguous-float-dots.scala:6: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - val x1 = 5.f - ^ -ambiguous-float-dots.scala:7: warning: Treating numbers with a leading zero as octal is deprecated. - val y0 = 055 - ^ -ambiguous-float-dots.scala:11: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - 1.+(2) - ^ -ambiguous-float-dots.scala:12: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - 1. + 2 - ^ -ambiguous-float-dots.scala:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 1.+(2) - ^ -ambiguous-float-dots.scala:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 1. + 2 - ^ -ambiguous-float-dots.scala:13: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 1 + 2 - ^ -error: No warnings can be incurred under -Xfatal-warnings. -8 warnings found -one error found diff --git a/test/files/neg/ambiguous-float-dots.flags b/test/files/neg/ambiguous-float-dots.flags deleted file mode 100644 index 65faf53579..0000000000 --- a/test/files/neg/ambiguous-float-dots.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -deprecation \ No newline at end of file diff --git a/test/files/neg/ambiguous-float-dots.scala b/test/files/neg/ambiguous-float-dots.scala deleted file mode 100644 index 87e948db35..0000000000 --- a/test/files/neg/ambiguous-float-dots.scala +++ /dev/null @@ -1,14 +0,0 @@ -class A { - val x0 = 5. -} - -class B { - val x1 = 5.f - val y0 = 055 -} - -class D { - 1.+(2) - 1. + 2 - 1 + 2 -} diff --git a/test/files/neg/ambiguous-float-dots2.check b/test/files/neg/ambiguous-float-dots2.check index 8919d2c6a8..40c9b4186d 100644 --- a/test/files/neg/ambiguous-float-dots2.check +++ b/test/files/neg/ambiguous-float-dots2.check @@ -1,10 +1,7 @@ -ambiguous-float-dots2.scala:7: error: Non-zero numbers may not have a leading zero. - val y0 = 055 - ^ ambiguous-float-dots2.scala:3: error: identifier expected but '}' found. } ^ -ambiguous-float-dots2.scala:12: error: ';' expected but integer literal found. +ambiguous-float-dots2.scala:11: error: ';' expected but integer literal found. 1. + 2 ^ -three errors found +two errors found diff --git a/test/files/neg/ambiguous-float-dots2.flags b/test/files/neg/ambiguous-float-dots2.flags deleted file mode 100644 index 112fc720a0..0000000000 --- a/test/files/neg/ambiguous-float-dots2.flags +++ /dev/null @@ -1 +0,0 @@ --Xfuture \ No newline at end of file diff --git a/test/files/neg/ambiguous-float-dots2.scala b/test/files/neg/ambiguous-float-dots2.scala index 87e948db35..b1615c9273 100644 --- a/test/files/neg/ambiguous-float-dots2.scala +++ b/test/files/neg/ambiguous-float-dots2.scala @@ -4,7 +4,6 @@ class A { class B { val x1 = 5.f - val y0 = 055 } class D { diff --git a/test/files/pos/t2081.scala b/test/files/pos/t2081.scala index d772c02dc2..f4f21600c6 100644 --- a/test/files/pos/t2081.scala +++ b/test/files/pos/t2081.scala @@ -7,5 +7,5 @@ object ScalaForRubyists { val x = 10.days // a couple parser corner cases I wanted not to break - val y = 5.e0 + 5e7 + val y = 5.0e0 + 5e7 } -- cgit v1.2.3