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

[BUG] Poor error message when a function signature uses a keyword that was removed/hasn't been added yet #3911

Open
nmsmith opened this issue Dec 25, 2024 · 0 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@nmsmith
Copy link
Contributor

nmsmith commented Dec 25, 2024

Bug description

In argument lists, if the compiler encounters two identifiers in succession, for example fn foo(a b), the compiler currently complains that it "expected )". This is not very informative. Most of the time, I'd wager the reason the programmer has written two identifiers is that they expected the first identifier to be a keyword. The Mojo compiler should account for this, and perhaps say something like:

Did not expect to encounter identifier b after identifier a. Note: a is not a keyword.

This improvement to error messages seems especially important for today's Mojo, given that in each new release of Mojo, new keywords are being introduced, and old keywords are being removed.

Steps to reproduce

Mojo 24.5 doesn't have the out keyword, so running the following program on 24.5 produces a mysterious error:

struct Foo:
    var x: Int
    fn __init__(out self, x: Int):
        self.x = x
error: expected ')' in argument list
    fn __init__(out self, x: Int):
                    ^

At least one Mojo learner has encountered this poor error message.

System information

No response

@nmsmith nmsmith added bug Something isn't working mojo-repo Tag all issues with this label labels Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

1 participant