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

Properly handle declarations at local scope #4284

Open
mohammadfawaz opened this issue Mar 14, 2023 · 3 comments
Open

Properly handle declarations at local scope #4284

mohammadfawaz opened this issue Mar 14, 2023 · 3 comments
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser compiler: ui Mostly compiler messages P: critical Should be looked at before anything else

Comments

@mohammadfawaz
Copy link
Contributor

For example, the following code results in an ICE:

script

fn foo() {
    struct S {}
}

ICE:

4 |     struct S {}
  |     ^^^^^^^^^^^ Internal compiler error: Unexpected struct declaration found.
Please file an issue on the repository and include the code that triggered this error.

Most declarations exhibit the same behavior, such as enums, storage decl, type aliases, etc.

At the very least, we should error out properly instead of throwing an ICE.

@mohammadfawaz mohammadfawaz added P: critical Should be looked at before anything else compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser compiler: ui Mostly compiler messages labels Mar 14, 2023
@otrho
Copy link
Contributor

otrho commented Mar 14, 2023

Wow. How did this stay a thing for so long?

@vaivaswatha
Copy link
Contributor

This isn't really an ICE, but an error that prints an ICE like message.

@mohammadfawaz
Copy link
Contributor Author

Hahaha... Toby added this UnexpectedDeclaration error which indeed should be an internal compiler error because we should be catching these issues much much earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser compiler: ui Mostly compiler messages P: critical Should be looked at before anything else
Projects
None yet
Development

No branches or pull requests

3 participants