Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPrevent bumping the parser past the EOF. #32479
Conversation
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
added
beta-nominated
T-compiler
labels
Mar 25, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors r- |
This comment has been minimized.
This comment has been minimized.
|
starting a crater run |
nagisa
reviewed
Mar 25, 2016
| if p.token == token::Semi { | ||
|
|
||
| // Don't bump past the EOF. | ||
| if p.token == token::Eof { |
This comment has been minimized.
This comment has been minimized.
nagisa
Mar 25, 2016
Contributor
To me it feels like at this point converting this chain to a match would be better here.
This comment has been minimized.
This comment has been minimized.
nagisa
reviewed
Mar 25, 2016
| self.open_braces.pop().unwrap(); | ||
|
|
||
| // Don't bump past the EOF. | ||
| if self.token != token::Eof { | ||
| self.bump(); |
This comment has been minimized.
This comment has been minimized.
nagisa
Mar 25, 2016
Contributor
Perhaps a utility function like self.bump_even_through_eof() would be suitable?
This comment has been minimized.
This comment has been minimized.
eddyb
Mar 25, 2016
Author
Member
That's just asking to be called in a loop instead of manually analyzing each use site.
This comment has been minimized.
This comment has been minimized.
|
Crater report: https://gist.github.com/nikomatsakis/416a719bf29fb0fa8028
haven't investigated yet. |
This comment has been minimized.
This comment has been minimized.
|
Looks like this breaks syntax extensions ( |
eddyb
force-pushed the
eddyb:eof-not-even-twice
branch
2 times, most recently
from
88c6a99
to
27a3e24
Mar 25, 2016
This comment has been minimized.
This comment has been minimized.
|
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? |
eddyb
force-pushed the
eddyb:eof-not-even-twice
branch
from
27a3e24
to
4b1db08
Mar 26, 2016
This comment has been minimized.
This comment has been minimized.
|
@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 |
eddyb
force-pushed the
eddyb:eof-not-even-twice
branch
2 times, most recently
from
8012a49
to
64936b9
Mar 26, 2016
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@BurntSushi The original changes would make |
eddyb
force-pushed the
eddyb:eof-not-even-twice
branch
from
64936b9
to
140210b
Mar 26, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@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. |
nagisa
referenced this pull request
Mar 26, 2016
Closed
Flood of unexpected token: `<eof>` errors triggered by foo(|_|) #32505
eddyb
added some commits
Mar 25, 2016
eddyb
force-pushed the
eddyb:eof-not-even-twice
branch
from
140210b
to
221d0fb
Mar 26, 2016
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
Sounds good On Sat, Mar 26, 2016 at 05:31:54AM -0700, Eduard-Mihai Burtescu wrote:
|
This comment has been minimized.
This comment has been minimized.
|
lgtm |
eddyb
referenced this pull request
Mar 28, 2016
Merged
Use parse_seq_to_before_end to keep the end token. #171
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
eddyb commentedMar 25, 2016
Makes
Parser::bumpafter 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.