`build (minBound :: Int)` renders as "-0"
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
Research direction
Start with Data/Text/Format/Int.hs at decimal, then reproduce the minBound examples for Int and Integer from the issue. Check the formatting behavior at the minimum representable values and verify that the result is never "-0" while the neighboring negative values remain unchanged.
Written by the indexing model from the issue text.
Description
We're using text-format-0.3.1.1
Data.Text.Buildable Prelude> build (minBound :: Int)
"-0"
Integer is also affected which is a weirder/worse case:
Data.Text.Buildable Prelude> build (-9223372036854775807 :: Integer)
"-9223372036854775807"
Data.Text.Buildable Prelude> build (-9223372036854775808 :: Integer)
"-0"
Data.Text.Buildable Prelude> build (-9223372036854775809 :: Integer)
"-9223372036854775809"
The bug is here:
decimal i
| i < 0 = minus <> go (-i) --- < HERE
| otherwise = go i
where
go n | n < 10 = digit n
| otherwise = go (n `quot` 10) <> digit (n `rem` 10)
Since negate minBound is not representable. In fact I wrote this bug myself a couple weeks ago :) . Will submit a little PR shortly.
- Dominant language
- Haskell
- Stars
- 34
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from haskell/text-format
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
haskell/text-format#27 · 3 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
haskell/text-format#26 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
haskell/text-format#25 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
haskell/text-format#22 · 3 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
haskell/text-format#20 ·
All issues in haskell/text-format
Similar issues
-
chore
Difficulty 1/5 Under an hour Newbie friendliness 91/100
alunduil/alunduil-chezmoi#792 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
koalaman/shellcheck#3539 ·
-
time-manager-0.4.0 Openfailure: bounds
Difficulty 1/5 Under an hour Newbie friendliness 72/100
commercialhaskell/stackage#8122 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
objectionary/phino#1350 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100