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 @@ -2882,14 +2882,18 @@ object Parsers {
2882
2882
*/
2883
2883
def pattern3 (location : Location ): Tree =
2884
2884
val p = infixPattern()
2885
- if location.inArgs && followingIsVararg() then
2885
+ if followingIsVararg() then
2886
2886
val start = in.skipToken()
2887
- p match
2888
- case p @ Ident (name) if name.isVarPattern =>
2889
- Typed (p, atSpan(start) { Ident (tpnme.WILDCARD_STAR ) })
2890
- case _ =>
2891
- syntaxError(em " `*` must follow pattern variable " , start)
2892
- p
2887
+ if location.inArgs then
2888
+ p match
2889
+ case p @ Ident (name) if name.isVarPattern =>
2890
+ Typed (p, atSpan(start) { Ident (tpnme.WILDCARD_STAR ) })
2891
+ case _ =>
2892
+ syntaxError(em " `*` must follow pattern variable " , start)
2893
+ p
2894
+ else
2895
+ syntaxError(em " bad use of `*` - sequence pattern not allowed here " , start)
2896
+ p
2893
2897
else p
2894
2898
2895
2899
/** 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