-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 matching Option with strictEquality #10850
Comments
Also on that topic, I would expect case classes to automatically derive a CanEqual as long as all fields have a CanEqual. E.g. // does not compile, but should in my opinion
case class A(v: Boolean)
A(true) == A(true)
// does compile
case class A(v: Boolean) derives CanEqual
A(true) == A(true) |
This is so annoying. I've hit it many times, and it basically makes It's arguably a bug, because a type test with the object's singleton type does work, and compiles fine: o match {
case Some(true) =>
case Some(false) =>
case _: None.type =>
} AFAIK this compiles to the same thing, and has the same semantics. So |
They're not the same: scala> val x: Seq[Int] = Vector()
val x: Seq[Int] = Vector()
scala> x match { case Nil => "yup"; case _ => "nope" }
val res0: String = yup
scala> x match { case _: Nil.type => "yup"; case _ => "nope" }
val res1: String = nope
|
Ah yeah, I was misremembering #9359 ( Still, I think |
I don't think I'll find the time to work on this for now. |
It should be fixed by #12419 and #13265 and as far as I know, it will be available in Scala 3.1.0. |
Minimized example
Output
Expectation
The example does not compile with
-language:strictEquality
in Scala 3.0.0-M3, because there is no predefined CanEqual for Option according to the documentation. So it is technically not a bug.To be honest I have not understood multiversal equality completely, yet. But for me it would make sense for this example to compile without providing a CanEqual as user for a Option type which is part of the Scala standard library. It makes also sense for me that something like
if Some(true) == None then ???
fails to compile with-language:strictEquality
, which it currently does.The text was updated successfully, but these errors were encountered: