Skip to content
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: change warning into an error on T<A=B, C> #33343

Merged
merged 1 commit into from
May 5, 2016

Conversation

birkenfeld
Copy link
Contributor

@birkenfeld birkenfeld commented May 2, 2016

part of #32214

This seems to be the obvious fix, and the error message is consistent with all the other parser errors ("expected x, found y").

@rust-highfive
Copy link
Collaborator

r? @nrc

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

@Manishearth
Copy link
Member

From the bug:

In either case, we should explain why there is an error here - because you can't have unbound type variables after bound ones.

@birkenfeld
Copy link
Contributor Author

I saw that, but what makes this one special compared to other syntax errors?

@Manishearth
Copy link
Member

We should still emit the expected blah found blah, but also emit extra help text that's in readable English instead of parsertongue 😛

@birkenfeld
Copy link
Contributor Author

Not that I disagree, but let me ask again: why is this parse error so special compared to the dozens of others which could get the same treatment?

I'd propose to start with this change to get rid of the strange warning, and to stop accepting invalid parses.

@Manishearth
Copy link
Member

why is this parse error so special compared to the dozens of others which could get the same treatment?

They should get the same treatment!

@bors r+ , in that case

however this does not fix #32214 completely 😄

@bors
Copy link
Contributor

bors commented May 2, 2016

📌 Commit 98d991f has been approved by Manishearth

@durka
Copy link
Contributor

durka commented May 2, 2016

I suggested a more helpful error (and then deleted the comment, but I forget why) but others said the parser should be pure and unaware of language constructs.

@Manishearth
Copy link
Member

I disagree. This is diagnostics, which is a very real concern. IIRC our parser still doesn't point out where you may have forgotten a semicolon, instead spitting out a cryptic parsertongue expected/found message. This is not a trivial thing to fix, but it's a pain point for people new to the language. In general the parsertongue errors don't help much.

I don't see any concrete benefit to keeping language constructs out of the parser -- it's more of an ideal, and ideals should not make concrete concerns like diagnostics suffer. As long as it's limited to where the errors are emitted, IMO we should be okay.

@durka
Copy link
Contributor

durka commented May 2, 2016

Parseltongue? 🐍

@Manishearth
Copy link
Member

No, parsertongue 😛

The language of the parser. tokens and such. Not necessarily readable/understandable, i.e. in the case of the error the parser emits here.

@durka
Copy link
Contributor

durka commented May 2, 2016

Yeah I mean, this code is in a function called parse_generic_values_after_lt so it seems a bit academic to pretend we don't know what construct it is.

And I'm in favor of renaming parsertongue to parseltongue :)

@birkenfeld
Copy link
Contributor Author

One argument that could be made against adding these diagnostics is that it becomes much harder to migrate them to a parser automatically generated from a grammar. I don't know if this is planned (or even possible anymore)?

On the other hand, there are parsers that don't formulate expectations in terms of tokens, but in terms of constructs (e.g. "expected associated type or >, found identifier"). This could already help a lot.

Manishearth added a commit to Manishearth/rust that referenced this pull request May 3, 2016
parser: change warning into an error on `T<A=B, C>`

part of rust-lang#32214

This seems to be the obvious fix, and the error message is consistent with all the other parser errors ("expected x, found y").
bors added a commit that referenced this pull request May 3, 2016
Rollup of 14 pull requests

- Successful merges: #33277, #33294, #33314, #33322, #33333, #33338, #33339, #33340, #33343, #33357, #33363, #33365, #33371, #33372
- Failed merges:
bors added a commit that referenced this pull request May 3, 2016
Rollup of 14 pull requests

- Successful merges: #33277, #33294, #33314, #33322, #33333, #33338, #33339, #33340, #33343, #33357, #33363, #33365, #33371, #33372
- Failed merges:
bors added a commit that referenced this pull request May 4, 2016
Rollup of 14 pull requests

- Successful merges: #33277, #33294, #33314, #33322, #33333, #33338, #33339, #33340, #33343, #33357, #33363, #33365, #33371, #33372
- Failed merges:
bors added a commit that referenced this pull request May 4, 2016
Rollup of 14 pull requests

- Successful merges: #33277, #33294, #33314, #33322, #33333, #33338, #33339, #33340, #33343, #33357, #33363, #33365, #33371, #33372
- Failed merges:
@bors bors merged commit 98d991f into rust-lang:master May 5, 2016
@birkenfeld birkenfeld deleted the issue-32214 branch May 6, 2016 04:06
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.

6 participants