-
Notifications
You must be signed in to change notification settings - Fork 808
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
Document (or fix?) the fact that escaped() succeeds on empty inputs #1735
Comments
If empty inputs were to be handled by the "normal" parser and propagate the error up, what would you expect From an implementation perspective, its as-if you were running with However, that wouldn't preclude a |
I don't follow. main parser gets The issue is about how There's also other issues with |
That was in response specifically to:
This doesn't match my experience with nom
|
Being in the |
I'm not seeing what in the docs is leading to that. However, when I look at the code,
I had misunderstood and thought you were keying off of whether a
|
|
This discussion is getting pretty tiresome, it has nothing to do with my actual issue (which is, at best a one line documentation change, and at worst a legitimate bug) The consistency doesn't actually matter. It's merely a supporting argument for why this edge case should be addressed. |
Combinators such as
many1
explicitly state they fail if the input parser accepts empty inputs. For this reason, most parsers likeis_not
fail on empty inputs.However,
escaped
immediately returnsOk
when given an empty input without even attempting to run the inner parser, which otherwise would correctly return an error, whichescaped
would then correctly pass up when it detects that the error was due to empty input. I'm unsure whether this is intentional or an oversight, as a code path doing the right thing does exist, but is not triggered.This leads to an issue where wrapping an existing parser in
escaped
can change its behaviour:https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e37a7669c47bed92d6853e788ba0725b
Workaround in my case seems to be wrapping the
escaped
inverify(..., |s: &str| !s.is_empty())
The text was updated successfully, but these errors were encountered: