Skip to content

parseField does not range-check for Word16 #211

Open
@jchia

Description

@jchia

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: haskell/attoparsec#211

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions