Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit b89ef77

Browse files
committed
Update documentation to make it clear [] => ... is invalid.
As @adriaanm pointed out, the grammar comment was wrong. Type lambdas require at least one type paramter. Even though the parser fails to accept `[] => ...` at an earlier point, I added a bit of error-checking to make sure that we never accept such a construction (at least until it has an accepted use/meaning).
1 parent 7717607 commit b89ef77

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ self =>
928928

929929
/** {{{
930930
* SimpleType ::= SimpleType TypeArgs
931-
* | `[' Types `]' `=>' Type
931+
* | `[' VariantTypeParam {`,' VariantTypeParam} `]'] `=>' Type
932932
* | SimpleType `#' Id
933933
* | StableId
934934
* | Path `.' type
@@ -944,7 +944,10 @@ self =>
944944
case LBRACKET =>
945945
atPos(start) {
946946
val ts = typeParamClauseOpt(freshTypeName("typelambda"), null)
947-
if (in.token == ARROW) {
947+
if (ts.isEmpty) {
948+
syntaxError("missing type parameters", skipIt = false)
949+
errorTypeTree
950+
} else if (in.token == ARROW) {
948951
in.skipToken()
949952
makeTypeLambdaTypeTree(ts, typ())
950953
} else {

0 commit comments

Comments
 (0)