cassava
cassava copied to clipboard
parseField does not range-check for Word16
There is an instance of ParseField for Word16 and I was expecting it to fail for an input of "65536" because it is out-of-range.
I was surprised to find out that "65536" parses as 0:
ghci> runParser $ parseField @Word16 "65536"
Right 0
I think parseField on bounded integral types should do the necessary range-checking. The parseField for Word16 currently uses decimal from attoparsec, which does not do range checking. This issue affects different bounded integral types, not just Word16.
Related attoparsec issue: https://github.com/haskell/attoparsec/issues/211