Skip to content

Better Error Message When Parsing Greek Question Mark (and similar confusing characters) #25957

Closed
@Havvy

Description

@Havvy

Current:

fn main() {
    let a = 5;
}
<anon>:2:14: 2:15 error: unknown start of token: \u{37e}
<anon>:2     let a = 5;
                      ^
playpen: application terminated with error code 101

Do you know what the error message is here? It's that I'm using the Greek Question Mark instead of a semicolon, causing a parse error. And while there is an error message, it's extremely opaque.

A better error message would actually print the token that is in error directly in the error message, e.g. as @niconii suggsted:

error: expected one of `.`, `;`, or an operator, found unicode character U+37E `;`

Using the human readable U+37E over the Rust encoding thing (\u{37E}) would definitely help.

In the specific case of the Greek Question Mark, it looks exactly like a semicolon, and symbols that look like other symbols are pretty common in Unicode, but perfectly enumerable. If we had a table of unicode point to actually used symbol, we could display an even better notice message:

error: expected one of `.`, `;`;, or an operator, found unicode character U+37E `;`

note: Unicode character U+37E (Greek Question Mark) looks like a semicolon, but is not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions