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

Overflow parsing uint64 #34

Closed
nick-phillips-dev opened this issue Sep 21, 2018 · 4 comments
Closed

Overflow parsing uint64 #34

nick-phillips-dev opened this issue Sep 21, 2018 · 4 comments

Comments

@nick-phillips-dev
Copy link

There isn't any error handling in this code: https://github.com/alecthomas/participle/blob/master/nodes.go#L302-L307

I'm trying to reject values larger than 2^64. When I add some logging in that block, I get this:

strconv.ParseUint: parsing "18446744073709551616": value out of range

However, the value I get is 1 with no parsing errors.

@alecthomas
Copy link
Owner

Ah, huh. Definitely needs a few failf calls in there.

@incognick
Copy link

I can make a PR if that will help. Would just need some direction.

@alecthomas
Copy link
Owner

That would be appreciated.

It just needs calls to panicf() in an else clause for each one.

If you don't get to it I will soonish.

@alecthomas
Copy link
Owner

Actually after taking a bit of a closer look I realised this is (somewhat) deliberate. If Participle encounters non-numeric tokens being captured into numeric fields it treats the field as a counter and increments it. That is useful for certain types of grammar features. On the other hand, it is also very confusing when you don't want that behaviour.

I think I will remove that feature. It can be replicated with a custom Capture implementation anyway.

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

3 participants