Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser.int and Parser.float handle leading Zeros unexpectedly #45

Open
maxmunzel opened this issue Apr 23, 2020 · 1 comment
Open

Parser.int and Parser.float handle leading Zeros unexpectedly #45

maxmunzel opened this issue Apr 23, 2020 · 1 comment

Comments

@maxmunzel
Copy link

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.

@asett0
Copy link

asett0 commented May 23, 2020

Just noticed this too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants