File tree 4 files changed +17
-9
lines changed
compiler/src/dotty/tools/dotc/parsing
4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -2908,14 +2908,18 @@ object Parsers {
2908
2908
*/
2909
2909
def pattern3 (location : Location ): Tree =
2910
2910
val p = infixPattern()
2911
- if location.inArgs && followingIsVararg() then
2911
+ if followingIsVararg() then
2912
2912
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
2919
2923
else p
2920
2924
2921
2925
/** 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