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

Comparison results concerning Array[Unit] contradict the warning of the compiler #4572

Open
scabug opened this issue May 12, 2011 · 1 comment

Comments

@scabug
Copy link

scabug commented May 12, 2011

=== What steps will reproduce the problem? ===

scala> (new Array[Unit](5))(0) == ()
<console>:10: warning: comparing values of types Unit and Unit using `==' will always yield true
       (new Array[Unit](5))(0) == ()
                               ^
res16: Boolean = false

scala> (new Array[Unit](5))(0) == null
<console>:10: warning: comparing values of types Unit and Null using `==' will always yield false
       (new Array[Unit](5))(0) == null
                               ^
res17: Boolean = true

scala> {val a = Array.fill(5)(()); a(0) == ()}
<console>:11: warning: comparing values of types Unit and Unit using `==' will always yield true
       {val a = Array.fill(5)(()); a(0) == ()}
                                        ^
res18: Boolean = true

=== What is the expected behavior? ===

  • There shouldn't be a difference between the first and the third example (assignment prior to comparison).

  • The compiler warning shouldn't contradict the actual result

  • Looking for () in an Array[Unit] should return true, not false

  • Looking for null in an Array[Unit] should return false, not true

=== What do you see instead? ===
Weirdness.

=== Additional information ===
This is probably related #4510.

=== What versions of the following are you using? ===

  • Scala: 2.10.0.r24908-b20110508020204
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

3 participants