Skip to content

fix(std): reject "-0" forms in stringToLong (#1582)#1585

Merged
julien-truffaut merged 1 commit into
optics-dev:masterfrom
SAY-5:fix-string-to-long-negzero-1582
May 14, 2026
Merged

fix(std): reject "-0" forms in stringToLong (#1582)#1585
julien-truffaut merged 1 commit into
optics-dev:masterfrom
SAY-5:fix-string-to-long-negzero-1582

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 13, 2026

Fixes #1582. stringToLong.getOption("-0") returned Some(0L) but reverseGet(0L) is "0", so the Prism round-trip law fails for negative-zero forms (-0, -00, -01, ...). Extend inputBreaksPrismLaws with a guard for any string starting with -0.

Per @julien-truffaut in #1582 (comment) ("Thanks for the bug report ... Feel free to send a PR :)"), with the guard expression matching the suggestion in the issue. Added unit tests in StringsSpec for both the rejected and the still-accepted shapes.

@julien-truffaut
Copy link
Copy Markdown
Member

Thank you! Approved

@julien-truffaut julien-truffaut merged commit cca90c5 into optics-dev:master May 14, 2026
11 checks passed
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

Successfully merging this pull request may close these issues.

monocle.std.string.stringToLong accepts "-0" and other negative-zero forms, breaks Prism law

2 participants