We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I think this deserves more than an "unchecked" warning:
scala> def f { | val (n, l): (String, Int) = (4, ""); | } warning: there were 2 unchecked warnings; re-run with -unchecked for details f: Unit scala> f java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String [...]
This is specially surprising because this other very similar case (created from #140, which I initially thought was the same bug) works as I expected:
scala> def g { | val (n: String, l: Int) = (4, ""); | } <console>:8: error: scrutinee is incompatible with pattern type; found : String required: Int val (n: String, l: Int) = (4, ""); ^ <console>:8: error: type mismatch; found : String required: Int val (n: String, l: Int) = (4, ""); ^ <console>:8: error: scrutinee is incompatible with pattern type; found : Int required: String val (n: String, l: Int) = (4, ""); ^ <console>:8: error: type mismatch; found : Int required: String val (n: String, l: Int) = (4, "");
The text was updated successfully, but these errors were encountered:
Imported From: https://issues.scala-lang.org/browse/SI-5106?orig=1 Reporter: @jsalvata Affected Versions: 2.9.0-1, 2.9.2 Other Milestones: 2.10.0
Sorry, something went wrong.
@jsalvata said: This is different from SUGGEST-4 -- those throw MatchErrors, not ClassCastExceptions. And none of the examples there is so blatant.
@adriaanm said: seems fixed in master:
scala> val (n, l): (String, Int) = (4, "") <console>:7: error: type mismatch; found : Int(4) required: String val (n, l): (String, Int) = (4, "") ^ <console>:7: error: type mismatch; found : String("") required: Int val (n, l): (String, Int) = (4, "") ^ scala> val (n: String, l: Int) = (4, ""); <console>:7: error: scrutinee is incompatible with pattern type; found : String required: Int val (n: String, l: Int) = (4, ""); ^ <console>:7: error: scrutinee is incompatible with pattern type; found : Int required: String val (n: String, l: Int) = (4, "");
adriaanm
No branches or pull requests
I think this deserves more than an "unchecked" warning:
This is specially surprising because this other very similar case (created from #140, which I initially thought was the same bug) works as I expected:
The text was updated successfully, but these errors were encountered: