File tree Expand file tree Collapse file tree 4 files changed +17
-9
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -2908,14 +2908,18 @@ object Parsers {
29082908 */
29092909 def pattern3 (location : Location ): Tree =
29102910 val p = infixPattern()
2911- if location.inArgs && followingIsVararg() then
2911+ if followingIsVararg() then
29122912 val start = in.skipToken()
2913- p match
2914- case p @ Ident (name) if name.isVarPattern =>
2915- Typed (p, atSpan(start) { Ident (tpnme.WILDCARD_STAR ) })
2916- case _ =>
2917- syntaxError(em " `*` must follow pattern variable " , start)
2918- p
2913+ if location.inArgs then
2914+ p match
2915+ case p @ Ident (name) if name.isVarPattern =>
2916+ Typed (p, atSpan(start) { Ident (tpnme.WILDCARD_STAR ) })
2917+ case _ =>
2918+ syntaxError(em " `*` must follow pattern variable " , start)
2919+ p
2920+ else
2921+ syntaxError(em " bad use of `*` - sequence pattern not allowed here " , start)
2922+ p
29192923 else p
29202924
29212925 /** Pattern2 ::= [id `@'] Pattern3
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg/i8715.scala:2:46 -----------------------------------------------------------------------------------
2+ 2 |def Test = List(42) match { case List(xs @ (ys*)) => xs } // error
3+ | ^
4+ | bad use of `*` - sequence pattern not allowed here
Original file line number Diff line number Diff line change 1+ @ main
2+ def Test = List (42 ) match { case List (xs @ (ys* )) => xs } // error
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments