Hi everyone,
I stumbled upon odd behaviour regarding leading zeros:
Observed
> Parser.run Parser.int "0123"
Ok 0 : Result (List Parser.DeadEnd) Int
> Parser.run Parser.float "0123"
Ok 0 : Result (List Parser.DeadEnd) Float
Expected
The documentation suggests that this would cause an Err-Result. (at least for Parser.int)
I personally expected python-like behaviour:
>>> int("0123")
123
>>> float("0123")
123.0
In any case, Ok 0 makes the user think, the input was correctly parsed, when in fact it was not.
Final Thoughts
I want to thank you for your work in the elm community and especially the nice design of the elm/parser. It's a blast to work with so far.
I'd be happy to contribute to a fix, if you too see this as a bug.
Hi everyone,
I stumbled upon odd behaviour regarding leading zeros:
Observed
Expected
The documentation suggests that this would cause an
Err-Result. (at least forParser.int)I personally expected python-like behaviour:
In any case,
Ok 0makes the user think, the input was correctly parsed, when in fact it was not.Final Thoughts
I want to thank you for your work in the elm community and especially the nice design of the
elm/parser. It's a blast to work with so far.I'd be happy to contribute to a fix, if you too see this as a bug.