You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seq(1, 2) matchcaseSeq(x, y*) => println(y) // prints List(2) which looks correctSeq(1, 2) matchcaseSeq(x, (y)*) => println(y) // parses, but gives a compiler error that y in the pattern is not found valy=3Seq(1, 2) matchcaseSeq(x, (y)*) => println(y) // compiles and outputs 3, which is curious because what did (y) match exactly then?
Output
Output for
Seq(1, 2) matchcaseSeq(x, (y)*) => println(y)
[error] -- [E006] NotFoundError:/dotty-test/src/main/scala/Main.scala:8:17
[error] 8|caseSeq(x, (y)*) => println(y)
[error] |^
[error] |Notfound: y
[error] -- [E006] NotFoundError:/dotty-test/src/main/scala/Main.scala:8:33
[error] 8|caseSeq(x, (y)*) => println(y)
[error] |^
[error] |Notfound: y
[error] two errors found
[error] two errors found
[error] (Compile/ compileIncremental) Compilation failed
Expectation
Not 100% sure what to expect... maybe something where the pattern matched multiple times?
It just looks only half implemented to me...
The text was updated successfully, but these errors were encountered:
For simplicity and consistency with Scala 2, maybe it's better to restore the following restrictions:
In pat: T, restrict pat to a pattern variable
in pat*, restrict pat to a pattern variable
There are currently no known use cases for the new features. If there is a strong need, the feature can come after 3.0, as it does not change the existing syntax.
It seems to be an accident. There is nothing except a pattern variable, or an _, that could possibly make sense in that context.
It was probably a side effect of allowing patterns on the left of : T, where @odersky argued that it made sense and should not be reverted. But for * it makes no sense.
Compiler version
3.0.0-RC2-bin-20210217-83cb8ff-NIGHTLY
Minimized code
Output
Output for
Expectation
Not 100% sure what to expect... maybe something where the pattern matched multiple times?
It just looks only half implemented to me...
The text was updated successfully, but these errors were encountered: