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

Confusing error when forgetting a semicolon before an array #99658

Closed
dullbananas opened this issue Jul 24, 2022 · 0 comments · Fixed by #100334
Closed

Confusing error when forgetting a semicolon before an array #99658

dullbananas opened this issue Jul 24, 2022 · 0 comments · Fixed by #100334
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dullbananas
Copy link

playground

Given the following code:

fn bar() -> [u8; 2] {
    foo() // missing semicolon
    [1, 2]
}

The current output is:

error: expected one of `.`, `?`, `]`, or an operator, found `,
 --> src/lib.rs:6:7
  |
6 |     [1, 2]
  |       ^ expected one of `.`, `?`, `]`, or an operator

This is very confusing unless you notice the missing semicolon. The error message should mention that foo()[1, 2] is interpreted as an indexing expression, with something like "error when parsing index expression".

@dullbananas dullbananas added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 24, 2022
@TaKO8Ki TaKO8Ki self-assigned this Jul 25, 2022
@bors bors closed this as completed in 354b831 Aug 10, 2022
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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants