-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Prevent bumping the parser past the EOF. #32479
Conversation
@bors r+ |
📌 Commit 4b00d0c has been approved by |
@bors r- |
starting a crater run |
if p.token == token::Semi { | ||
|
||
// Don't bump past the EOF. | ||
if p.token == token::Eof { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it feels like at this point converting this chain to a match
would be better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish loop
-match
was a bit more first-class, but I agree.
Crater report: https://gist.github.com/nikomatsakis/416a719bf29fb0fa8028
haven't investigated yet. |
Looks like this breaks syntax extensions ( |
88c6a99
to
27a3e24
Compare
cc @BurntSushi @kevinmehall -- curious to get your take here. In response to various bugs where the parser was looping infinitely, @eddyb implemented a change that caused the @eddyb, I know you were attempting to modify the PR to only abort if we bumped past EOF multiple times, what was the outcome of those experiments? |
27a3e24
to
4b1db08
Compare
@nikomatsakis Actually, that's the current state, but I realize right now that I can just handle the error case by not bumping, and I just pushed that change. EDIT: Hah, it's not that easy, you can have both errors and a |
8012a49
to
64936b9
Compare
@nikomatsakis I'm totally fine with breakage of plugins if there's a path to fixing them. With that said, what part of the parsing code would break? Regex's interaction with the parser is quite small: https://github.com/rust-lang-nursery/regex/blob/master/regex_macros/src/lib.rs#L567 I guess it's clearer where it breaks in docopt: https://github.com/docopt/docopt.rs/blob/master/docopt_macros/src/macro.rs#L234 |
@BurntSushi The original changes would make |
64936b9
to
140210b
Compare
|
@kevinmehall Changing that shouldn't be necessary with my latest attempt - just waiting for travis to confirm everything's good with the tests before starting another crater run. |
140210b
to
221d0fb
Compare
@nrc See my changes to { option.map(|some| 42; } It currently parses as the following TTs: { option.map(|some| 42;) } It accidentally gave relatively sane errors because { option.map(|some| 42)) } I fixed that so it behaves as it should, given what TTs we end up with, but if we didn't parse it to TTs, we could recover a statement based on { option.map(|some| 42); } Which is arguably what the intention was, and save for a single parse error, the compilation could continue unhindered. |
Sounds good On Sat, Mar 26, 2016 at 05:31:54AM -0700, Eduard-Mihai Burtescu wrote:
|
lgtm |
@bors r=nikomatsakis |
📌 Commit 221d0fb has been approved by |
⌛ Testing commit 221d0fb with merge a111297... |
Prevent bumping the parser past the EOF. Makes `Parser::bump` after EOF into an ICE, forcing callers to avoid repeated EOF bumps. This ICE is intended to break infinite loops where EOF wasn't stopping the loop. For example, the handling of EOF in `parse_trait_items`' recovery loop fixes #32446. But even without this specific fix, the ICE is triggered, which helps diagnosis and UX. This is a `[breaking-change]` for plugins authors who eagerly eat multiple EOFs. See docopt/docopt.rs#171 for such an example and the necessary fix.
Makes
Parser::bump
after EOF into an ICE, forcing callers to avoid repeated EOF bumps.This ICE is intended to break infinite loops where EOF wasn't stopping the loop.
For example, the handling of EOF in
parse_trait_items
' recovery loop fixes #32446.But even without this specific fix, the ICE is triggered, which helps diagnosis and UX.
This is a
[breaking-change]
for plugins authors who eagerly eat multiple EOFs.See docopt/docopt.rs#171 for such an example and the necessary fix.