-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Parser silent exit on invalid input #63288
Comments
This is caused by the parser's error recovery mechanisms. When encountering these kind of situation, errors are always emitted (as shown above being printed out) if recoverable or returned. If you are trying to use the parser in a strict mode, that should be added as a config flag to it. There are also invocations to |
@estebank thanks for your reply. I took a closer look at the parser and it raises a FatalError (line 599) for my input. What I don't understand is why some parse errors are emitted, some are returned as an Err variant of the PResult struct and some panic. Can you explain the difference or can you provide links where I can read about this topic? Thanks in advance! |
Part of the problem you're facing is that |
We should probably be clear that libsyntax is written and maintained essentially for just rustc; it is not really a general use Rust parser. Also, discussions/questions like this should happen either on chat (e.g. rust-lang.zulipchat.com) or internals, the issue tracker is for bugs only. Thanks! |
I'm using rustc's parser (
parse_crate_mod
more specifically) as part of a program I'm writing and for some inputs, the parser terminates my program.Using the current nightly and
fn test(a
as the input, the following code terminates without printing the parsing result:Full test repository
Output:
For other invalid code (e.g.
fn test() ->
), the parser correctly returns an Err result:Is this a bug or am I missing something?
Thanks in advance.
The text was updated successfully, but these errors were encountered: