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

Obviously wrong warning when comparing fresh objects #5648

Closed
scabug opened this issue Apr 7, 2012 · 4 comments
Closed

Obviously wrong warning when comparing fresh objects #5648

scabug opened this issue Apr 7, 2012 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 7, 2012

The result make the warning obviously wrong:

scala> case class C(val s: Int*)
defined class C

scala> new C(1, 3, 7) == new C(1, 3, 7)
:10: warning: comparing a fresh object using `==' will always yield false
new C(1, 3, 7) == new C(1, 3, 7)
^
res4: Boolean = true

@scabug
Copy link
Author

scabug commented Apr 7, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5648?orig=1
Reporter: Romain Reuillonr (romain)
Affected Versions: 2.10.0-M2

@scabug
Copy link
Author

scabug commented Apr 9, 2012

@som-snytt said:
That depends on your definition of obviously.

As Paul said previously: "A warning might be possible, but it's harder than it looks to warn where you want to without creating spurious warnings elsewhere."

The bug is due to handling case class comparisons like Some. A simpler example:

scala> new Some(1) == Some(1)
<console>:8: warning: comparing a fresh object using `==' will always yield false
              new Some(1) == Some(1)
                          ^
res1: Boolean = true

I can request a pull with a tweak, after I check all the spurious warnings elsewhere, obviously.

@scabug
Copy link
Author

scabug commented Apr 10, 2012

@paulp said:
I already pushed a fix for this, but it can be improved. Also, the world of name mangling bugs became more interesting recently with #5652, if you didn't see that one.

@scabug
Copy link
Author

scabug commented Apr 10, 2012

@paulp said:
00e9446bfc

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

No branches or pull requests

2 participants