-
Notifications
You must be signed in to change notification settings - Fork 790
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
Consumer.run() panics when consume() requests more data than available #78
Comments
There are two points of view here:
I would be more inclined to the second option, since it helps for more parsers. In both cases, though, it should not fail allocating the slice. I even think it should always return the largest slice possible (all of the accumulated bytes) and let What do you think? |
I agree: The second option is clearly superior in terms of flexibility. The issue that I see with that is that existing code might do something like In short,
Alternatively, you could have callbacks about incomplete input, but I really can't come up with an idea that feels optimal. |
FYI I fixed the crash in 9f5128c, but I will not modify much the current design of producers and consumers, since I plan to change them completely for the 1.0 version. They're rather slow, and not really flexible, and I want to change that. The good news is that your suggestions on a new design are very welcome :) |
Please indicate your suggestions in #80 :) |
The stream feature will be removed in the next nom version (4.0), since commit 564a934. If someone wants to extract the code and maintain it, feel free to do it, it's in |
The run() method currently doesn't check correctly whether the producer has given it enough data to meet what the consume() method requested. You'll drop out of the data collection loop because you are at eof (same thing could happen because of a
ProducerError
as well), withneeded > acc.len()
, and then try to get a slice that extends beyond the end of the buffer.This test case demonstrates the problem:
The right thing would probably be to call
failed()
, but that usually takes error codes produced by the consumer as an argument, so I'm not sure what to do here.The text was updated successfully, but these errors were encountered: