haskell / haskell/attoparsec

decimal does not range-check

Open
#211 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
531
Forks
98
PR merge metrics
No merged PRs in 30d

Description

I just realized that `decimal` does not check for out-of-range values.
https://hackage.haskell.org/package/attoparsec-0.14.4/docs/src/Data.Attoparsec.ByteString.Char8.html#decimal

```
ghci> parseOnly (decimal @Word16) "65536"
Right 0
```

This was surprising to me, but only before considering the type constraint of Integral without Bounded, implying that range check is impossible.

Still, from the user's perspective, doing the appropriate range checks somewhere is necessary, if not by the library then by the user. If done by the user, he can only parse a Natural and the Word16 specialization becomes useless/unused.

Currently, this behavior carries over to cassava, which also fails to do the necessary range-check.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.