Skip to content
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

Pattern matcher warns about unreachability #6790

Closed
scabug opened this issue Dec 9, 2012 · 3 comments
Closed

Pattern matcher warns about unreachability #6790

scabug opened this issue Dec 9, 2012 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Dec 9, 2012

(This should really be 2.10.0-RC5, but JIRA would not let me enter that.)

I emailed scala-internals about this issue. Basically, I have a pattern match that under RC3 and earlier did not issue any warnings but which now gives the following:

[warn] /Users/erik/w/spire/src/main/scala/test.scala:2: Cannot check match for unreachability. [warn] (The analysis required more space than allowed. Please try with scalac -Dscalac.patmat.analysisBudget=512 or -Dscalac.patmat.analysisBudget=off.) [warn] def qux(s: String): String = s match { [warn] ^ [warn] one warning found

The suggestion (upping the analysis budget) does work, but I wonder if maybe there is a bug, since the pattern to be checked is relatively simple (a bunch of literal strings terminated by a wildcard). I have attached the test case I used.

@scabug
Copy link
Author

scabug commented Dec 9, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6790?orig=1
Reporter: @non
Affected Versions: 2.10.0-RC5
Duplicates #6942
Attachments:

  • test.scala (created on Dec 9, 2012 6:20:09 AM UTC, 812 bytes)

@scabug
Copy link
Author

scabug commented Dec 9, 2012

@paulp said:
A pattern built from all literals will become a switch if they're Int or smaller-Int, but other literals are given a hefty N^2 tax while the pattern matcher searches for unreachable code in rather inefficient fashion. It should be easy to fix.

@scabug
Copy link
Author

scabug commented Jan 19, 2013

@retronym said (edited on Jan 19, 2013 11:27:58 AM UTC):
Duplicate of #6942, i've confirmed that the open pull request fixes this example.

1915 ~/code/scala2 git describe 
v2.10.0-311-g964776f
1915 ~/code/scala2 ./build/quick/bin/scalac -unchecked sandbox/test.scala
1915 ~/code/scala2 scalac210 -unchecked sandbox/test.scala
sandbox/test.scala:2: warning: Cannot check match for unreachability.
(The analysis required more space than allowed. Please try with scalac -Dscalac.patmat.analysisBudget=512 or -Dscalac.patmat.analysisBudget=off.)
  def qux(s: String): String = s match {
                               ^
one warning found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants