Skip to content

parser: fix suppression of syntax errors in range RHS #33311

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

Merged
merged 1 commit into from
May 7, 2016

Conversation

birkenfeld
Copy link
Contributor

Invalid expressions on the RHS were just swallowed without generating an error. The new version more closely mirrors the code for parsing ..x in the parse_prefix_range_expr method below, where no cancel is done either.

Fixes #33262.

@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

Invalid expressions on the RHS were just swallowed without generating
an error.  The new code more closely mirrors the code for parsing
`..x` in the `parse_prefix_range_expr` method, where no cancel is done
either.

Fixes rust-lang#33262.
@jseyfried
Copy link
Contributor

LGTM, but r? @nrc -- there may be a reason this was not done in #30723 that I'm not seeing.

@nrc
Copy link
Member

nrc commented May 2, 2016

I don't think it is that simple, this seems to be an experimental parse, where if we can't parse as the rhs we parse the range as open on the right (foo..) and try to parse whatever was on the right as something else. Thus, why we cancel the error.

I'm not actually sure that will work, I think we would need to rewind any tokens eaten while we did that parse, and there is no way to do that afaik. So the logic may be broken or it might be that to fix #33262 the error should be found and reported elsewhere, I only had a cursory look at the code so I'm not sure.

cc @durka

@birkenfeld
Copy link
Contributor Author

@nrc I was thinking about that, and found two questions:

@nrc
Copy link
Member

nrc commented May 2, 2016

Hmm, looking closer at the history, we should probably emit instead of cancelling here, it might be worth doing that explicitly and trying to recover, but probably not. I think this PR is correct.

shouldn't ... use the same strategy?

yeah, looks like the cancel was an ad hoc fix for an ICE, rather than a deliberate strategy.

the intention appears to be that if is_at_start_of_range_notation_rhs returns true, the parse as expression must succeed - why have such a guard predicate otherwise?

Agreed.

@bors: r+

@bors
Copy link
Collaborator

bors commented May 2, 2016

📌 Commit a36fb46 has been approved by nrc

@birkenfeld
Copy link
Contributor Author

Thanks for the review!

@bors
Copy link
Collaborator

bors commented May 3, 2016

⌛ Testing commit a36fb46 with merge 2f9a29c...

@bors
Copy link
Collaborator

bors commented May 3, 2016

💔 Test failed - auto-win-msvc-64-opt-rustbuild

@alexcrichton
Copy link
Member

@bors: retry

I just restarted the buildmaster which should hopefully fix this issue.

On Tue, May 3, 2016 at 4:23 AM, bors [email protected] wrote:

[image: 💔] Test failed - auto-win-msvc-64-opt-rustbuild
http://buildbot.rust-lang.org/builders/auto-win-msvc-64-opt-rustbuild/builds/974


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#33311 (comment)

@alexcrichton
Copy link
Member

@bors: retry

@bors
Copy link
Collaborator

bors commented May 7, 2016

⌛ Testing commit a36fb46 with merge 6478583...

bors added a commit that referenced this pull request May 7, 2016
parser: fix suppression of syntax errors in range RHS

Invalid expressions on the RHS were just swallowed without generating an error.  The new version more closely mirrors the code for parsing `..x` in the `parse_prefix_range_expr` method below, where no cancel is done either.

Fixes #33262.
@bors bors merged commit a36fb46 into rust-lang:master May 7, 2016
@birkenfeld birkenfeld deleted the issue33262 branch May 7, 2016 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing error message
7 participants