Skip to content

Pattern sequence 'Pattern2*' is allowed by grammar, but behaves strange #11457

Closed
@SrTobi

Description

@SrTobi

Compiler version

3.0.0-RC2-bin-20210217-83cb8ff-NIGHTLY

Minimized code

Seq(1, 2) match
    case Seq(x, y*) => println(y) // prints List(2) which looks correct

Seq(1, 2) match
  case Seq(x, (y)*) => println(y) // parses, but gives a compiler error that y in the pattern is not found 

val y = 3
Seq(1, 2) match
  case Seq(x, (y)*) => println(y) // compiles and outputs 3, which is curious because what did (y) match exactly then?

Output

Output for

Seq(1, 2) match
  case Seq(x, (y)*) => println(y) 
[error] -- [E006] Not Found Error: /dotty-test/src/main/scala/Main.scala:8:17 
[error] 8 |    case Seq(x, (y)*) => println(y)
[error]   |                 ^
[error]   |                 Not found: y
[error] -- [E006] Not Found Error: /dotty-test/src/main/scala/Main.scala:8:33 
[error] 8 |    case Seq(x, (y)*) => println(y)
[error]   |                                 ^
[error]   |                                 Not found: 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...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions