question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide CanEqual for Option (Option == None), Throwables, and other

See original GitHub issue

Minimized code

x match {
  case Some(value) =>
  case None =>
}

Output

[error] 129 |					case None =>
[error]     |					     ^^^^
[error]     |					     Values of types object None and Option[T] cannot be compared with == or !=.
[error]     |					     I found:
[error]     |
[error]     |					         CanEqual.canEqualOptions[T, U](/* missing */summon[CanEqual[T, U]])
[error]     |
[error]     |					     But no implicit values were found that match type CanEqual[T, U].

Expectation

CanEqual instance should come already defined for at the very least, the standard library. You have to strike a balance between versatility and usability.

As it is currently, -language:strictEquality is too cautious to be useful.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
oderskycommented, Jun 25, 2022

The problem is that the CanEqual instance would logically have to be in the companion object of Option. But we cannot touch the standard library for the time being, since we want to use 2.13.

At some point we need to decide that we will ship a Scala 3 specific standard library, and in that case CanEqual instances would be provided. Until then, I agree that -language:strictEquality is not useful and should be avoided.

0reactions
Kevin-Leecommented, Jul 8, 2022

@strelec Do you still have this problem? Are you using Scala 3.0.x? It should be fixed by #12419 and #13265 in Scala 3.1.0 and higher.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Scala 3, is there a way to disable -language:strictEquality ...
Try limiting the scope of givens like so val x: Option[Throwable] = None { given CanEqual[Option[Throwable], Option[Throwable]] ...
Read more >
OptionSugar - scalactic_2.13 3.2.4 javadoc - javadoc.io
Trait providing an implicit class that adds a toOr method to Option , which converts Some to Good , None to Bad ....
Read more >
Scala Standard Library 2.13.3 - scala.Option
Represents optional values. Instances of Option are either an instance of scala.Some or the object None . The most idiomatic way to use...
Read more >
play.api.Configuration
def reportError (path: String, message: String, e: Option[Throwable] = None): PlayException. Creates a configuration error for a specific configuration key.
Read more >
Scaladoc for org.scalatest.events.InfoProvided
In this respect InfoProvided is different from the other events, ... the nameInfo of the InfoProvided event (an Option[NameInfo] ) should be None...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found