typelevel / typelevel/cats

catsSyntaxEq returns false for equality of positive and negative zero in Option

Open
#4,807 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

With versions:

  • Scala 3.3.3
  • cats-core 2.13.0

When comparing Options which contain doubles, catsSyntaxEq === unexpectedly returns false for comparisons of 0.0 and -0.0

scala> 0.0 === -0.0
val res2: Boolean = true

scala> Option(0.0) === Option(-0.0)
val res0: Boolean = false

This does not match Scala's behavior of

scala> Option(0.0) == Option(-0.0)
val res1: Boolean = true

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the comparison using Scala 3.3.3 and cats-core 2.13.0, starting from the catsSyntaxEq === entry point with Option(0.0) and Option(-0.0). Trace the Option equality behavior and add coverage showing the expected result agrees with Scala's Option equality; done when the positive and negative zero comparison behaves consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.