From f3f1e5060efe45eb01040f8332506c8c1dd26cfc Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 29 Sep 2012 16:24:43 -0700 Subject: SI-5353, imperfect error message. [backport] The fix of course is a perfect error message. --- test/files/neg/t5353.check | 4 ++++ test/files/neg/t5353.scala | 3 +++ test/files/neg/t5692a.check | 2 +- test/files/neg/t5692b.check | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 test/files/neg/t5353.check create mode 100644 test/files/neg/t5353.scala (limited to 'test/files/neg') diff --git a/test/files/neg/t5353.check b/test/files/neg/t5353.check new file mode 100644 index 0000000000..75e2435600 --- /dev/null +++ b/test/files/neg/t5353.check @@ -0,0 +1,4 @@ +t5353.scala:2: error: this type parameter must be specified + def f(x: Boolean) = if (x) Array("abc") else Array() + ^ +one error found diff --git a/test/files/neg/t5353.scala b/test/files/neg/t5353.scala new file mode 100644 index 0000000000..1ee869aac1 --- /dev/null +++ b/test/files/neg/t5353.scala @@ -0,0 +1,3 @@ +class A { + def f(x: Boolean) = if (x) Array("abc") else Array() +} diff --git a/test/files/neg/t5692a.check b/test/files/neg/t5692a.check index ded95a8820..7fbfb5dba7 100644 --- a/test/files/neg/t5692a.check +++ b/test/files/neg/t5692a.check @@ -1,4 +1,4 @@ -Test_2.scala:2: error: type parameter not specified +Test_2.scala:2: error: this type parameter must be specified def x = Macros.foo ^ one error found diff --git a/test/files/neg/t5692b.check b/test/files/neg/t5692b.check index e453870ec8..16796826b4 100644 --- a/test/files/neg/t5692b.check +++ b/test/files/neg/t5692b.check @@ -1,4 +1,4 @@ -Test_2.scala:2: error: type parameters not specified +Test_2.scala:2: error: these type parameters must be specified def x = Macros.foo ^ one error found -- cgit v1.2.3 From d2316df920ffa4804fe51e8f8780240c46efa982 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 3 Nov 2012 10:07:48 -0700 Subject: SI-6426, importable _. [backport] Prohibit `_` as an identifier, it can only bring badness. --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 7 ++----- src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 5 ++++- test/files/neg/t6426.check | 7 +++++++ test/files/neg/t6426.scala | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 test/files/neg/t6426.check create mode 100644 test/files/neg/t6426.scala (limited to 'test/files/neg') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 33db4ee2d5..c508e14343 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -980,11 +980,8 @@ self => /** Assumed (provisionally) to be TermNames. */ def ident(skipIt: Boolean): Name = - if (isIdent) { - val name = in.name.encode - in.nextToken() - name - } else { + if (isIdent) rawIdent().encode + else { syntaxErrorOrIncomplete(expectedMsg(IDENTIFIER), skipIt) nme.ERROR } diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 4f564c5d0b..45df318e40 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -607,7 +607,10 @@ trait Scanners extends ScannersCommon { if (ch == '`') { nextChar() finishNamed(BACKQUOTED_IDENT) - if (name.length == 0) syntaxError("empty quoted identifier") + if (name.length == 0) + syntaxError("empty quoted identifier") + else if (name == nme.WILDCARD) + syntaxError("wildcard invalid as backquoted identifier") } else syntaxError("unclosed quoted identifier") } diff --git a/test/files/neg/t6426.check b/test/files/neg/t6426.check new file mode 100644 index 0000000000..149f74c4de --- /dev/null +++ b/test/files/neg/t6426.check @@ -0,0 +1,7 @@ +t6426.scala:4: error: wildcard invalid as backquoted identifier + println(`_`.Buffer(0)) + ^ +t6426.scala:5: error: ')' expected but '}' found. +} +^ +two errors found diff --git a/test/files/neg/t6426.scala b/test/files/neg/t6426.scala new file mode 100644 index 0000000000..a27d18eb58 --- /dev/null +++ b/test/files/neg/t6426.scala @@ -0,0 +1,5 @@ +class A { + import collection.{mutable => _, _} + + println(`_`.Buffer(0)) +} -- cgit v1.2.3