-
Notifications
You must be signed in to change notification settings - Fork 805
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
recognize
can crash with 'attempt to subtract with overflow'
#1520
Comments
Yeah, you can't do that. The "rest" you return needs to be a subslice of your input. |
You're violating |
Yes, this is clear. I'm suggesting that the invariants could be checked with a debug assert (or perhaps some other mechanism), to save future users some debugging time. |
I'd say it's probably easy enough for anyone to open a PR for that. I can do it for you if you want. |
If you write a parser that returns a constant string in the first tuple position, and you pass that to recognize, you can crash in a very strange way. The reason is pretty obvious now that I tracked it down: recongize uses 'offset', which relies on the returned string being a subslice of the input.
It would be nice if there was a debug assertion in there, at least, to do a bounds check and provide a more helpful panic message.
For posterity, this is the output:
The text was updated successfully, but these errors were encountered: