Skip to content

Unreachable case for String interpolation match #8758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chungonn opened this issue Apr 21, 2020 · 0 comments · Fixed by #8789
Closed

Unreachable case for String interpolation match #8758

chungonn opened this issue Apr 21, 2020 · 0 comments · Fixed by #8789
Assignees

Comments

@chungonn
Copy link

The following code works on 2.13.1 but with dotty 0.23.0-RC1, i get a Unreachable case warning

"?johndoe" match {
  case s":$name" => println(s":name $name")
  case s"{$name}" =>  println(s"{name} $name")
  case s"?$pos" =>  println(s"pos $pos")
}

Output

3 |  case s"{$name}" =>  println(s"{name} $name")
  |       ^^^^^^^^^^
  |       Unreachable case
4 |  case s"?$pos" =>  println(s"pos $pos")
  |       ^^^^^^^^
  |       Unreachable case
pos johndoe
@liufengyun liufengyun self-assigned this Apr 21, 2020
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 24, 2020
The extractor `StringContext#s.unapplySeq` may have different prefix,
thus we may not assume they are the same.
nicolasstucki added a commit that referenced this issue Apr 24, 2020
Fix #8758: strengthen the precondition for comparing extractors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants