Skip to content

Better diagnostics for let = (let = #30440

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

Closed
steveklabnik opened this issue Dec 17, 2015 · 5 comments · Fixed by #31211
Closed

Better diagnostics for let = (let = #30440

steveklabnik opened this issue Dec 17, 2015 · 5 comments · Fixed by #31211
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@steveklabnik
Copy link
Member

This code isn't valid Rust:

let x = (let y = 6);

We have an okay, but not great, diagnostic here:

src/main.rs:2:14: 2:17 error: expected identifier, found keyword `let`
src/main.rs:2     let x = (let y = 6);
                           ^~~
src/main.rs:2:18: 2:19 error: expected one of `!`, `)`, `,`, `.`, `::`, `{`, or an operator, found `y`
src/main.rs:2     let x = (let y = 6);
                               ^

It might be nice to add a note when the keyword found is let that mentions that let is not an expression, and so cannot be used in this way.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Dec 17, 2015
@Manishearth Manishearth added the A-parser Area: The lexing & parsing of Rust source code to an AST label Dec 29, 2015
@Manishearth
Copy link
Member

@wafflespeanut want to work on this? It's a similar task to the other doc comment one, but much simpler since it's a very specific situation.

@wafflespeanut
Copy link
Contributor

I'd be happy to help someone :)

@Manishearth Manishearth added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jan 4, 2016
@wafflespeanut
Copy link
Contributor

So, the parser already has its ways to differentiate keywords from identifiers. All we have to do is find the right place where that error is thrown, check whether it's a let and add a note along with the error. The parser has all sorts of code, and adding a note's also around there somewhere :)

Code: src/libsyntax/parse/parser.rs

@dsprenkels
Copy link
Contributor

I would like to try this. :)

@Manishearth Manishearth self-assigned this Jan 5, 2016
@Manishearth
Copy link
Member

Awesome! Feel free to ask waffles or me for help (you can find us both on IRC on #rust-internals), or ask questions here.

(self-assigning since I can't assign to you -- just to mark it as "being taken")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants