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

"error: expected one of ,, ., ?, or an operator" list is incomplete #38777

Closed
Timmmm opened this issue Jan 2, 2017 · 6 comments · Fixed by #51099
Closed

"error: expected one of ,, ., ?, or an operator" list is incomplete #38777

Timmmm opened this issue Jan 2, 2017 · 6 comments · Fixed by #51099
Labels
A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@Timmmm
Copy link
Contributor

Timmmm commented Jan 2, 2017

Take this real code I just wrote:

	let text = Text::new()
					.set("x", 200) 
					.set("y", lifetime.starting_line*20 + 20)
					.set("class", "annotation")
					.add(svg::node::Text::new(markdown::to_html(&lifetime.markdown));

It gives this error:

note: unclosed delimiter
   --> src\main.rs:142:11
    |
142 | 						.add(svg::node::Text::new(markdown::to_html(&lifetime.markdown));
    | 						    ^

error: expected one of `,`, `.`, `?`, or an operator, found `;`
   --> src\main.rs:142:71
    |
142 | 						.add(svg::node::Text::new(markdown::to_html(&lifetime.markdown));
    | 						                                                                ^

Ok so it does give me a note about an unclosed delimiter, but the actual error says

error: expected one of `,`, `.`, `?`, or an operator, found `;`

I'm pretty sure ) isn't an operator, so isn't that list wrong? Shouldn't it say

error: expected one of `,`, `.`, `?`, `)`, or an operator, found `;`
@Mark-Simulacrum Mark-Simulacrum added the A-parser Area: The parsing of Rust source code to an AST label May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@Crazycolorz5
Copy link
Contributor

I'll look into this.

@Timmmm
Copy link
Contributor Author

Timmmm commented May 26, 2018

Also think about this again, if the unexpected symbol is ; it's pretty guaranteed that it is a missing bracket so you could give a much friendlier message, and even a fixit in that case (insert an appropriate number of )s before the semicolon.

@Crazycolorz5
Copy link
Contributor

I'm not sure how implementing a fixit would work. I can say that counting the number of appropriate )'s is nontrivial due to the recursive nature of the parser, though. But recursively inserting them to terminate sequences (to recover from an error) should be fairly simple.

@Timmmm
Copy link
Contributor Author

Timmmm commented May 26, 2018

Yeah I dont know how the parser works but the logic should be something like "if I found a ; but there aren't enough )'s, offer enough )'s so that they match". If that's not easy then fair enough.

@Crazycolorz5
Copy link
Contributor

Well, also, I don't believe that we should accept programs with unclosed parens. I believe the current behavior of printing an error should be correct.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 8, 2018
…estebank

Fix Issue 38777

When looking through for a closing bracket in the loop condition, adds them to expecteds.
rust-lang#38777
@Timmmm
Copy link
Contributor Author

Timmmm commented Jun 9, 2018

I didn't mean that the parser should actually add them in - it should offer a fixit.

Good work on fixing this anyway - a fixit can be added later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants