Skip to content

Getting unintended panic #128

Answered by zesterer
Vaimer9 asked this question in Q&A
Apr 19, 2022 · 2 comments · 9 replies
Discussion options

You must be logged in to vote

This panic happens because the parser matched a repeating pattern without consuming any input. This is almost always a bug in the parser (and it's common enough that I chose to add a panic for it). For example:

let a_chain = just('a').repeated();

let a_chain_chain = a_chain.repeated();

This parser will loop infinitely on the input b because the first parser, a_chain, is permitted to consume none of the input, and a_chain_chain looks for that input many times, leading to an infinite loop.

In your parser, you have .or_not().repeated(). This is highly suspect: or_not is permitted to consume no inputs (as in the example I gave) and repeated will look for that pattern many times. I would sugg…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Vaimer9
Comment options

You must be logged in to vote
9 replies
@Vaimer9
Comment options

@zesterer
Comment options

@zesterer
Comment options

@Vaimer9
Comment options

@Vaimer9
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants