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 support nested items or emit not-implemented error #6919

Open
ironcev opened this issue Feb 11, 2025 · 0 comments
Open

Properly support nested items or emit not-implemented error #6919

ironcev opened this issue Feb 11, 2025 · 0 comments
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team

Comments

@ironcev
Copy link
Member

ironcev commented Feb 11, 2025

Currently, inside of the compiler we support nested items and only nested functions are explicitly not supported and having them in code will emit a not-implemented error. For other kind of items, the level of support varies and can end in different kinds of issues.

E.g., the below example compiles with errors shown:

script;

struct S { }

impl S {
    const C: u8 = 0; 
}

fn a() {
    struct S { }   // <<<--- ERROR: Name "S" is defined multiple times.
    
    impl S {
        const C: u8 = 1; // <<<--- ERROR: Duplicate definitions for the constant "C" for type "S".
    }
}

fn main() {
    a();
}

On the other hand, removing the outer S results in an ICE:

script;

fn a() {
    struct S { }
//  ^^^^^^^^^^^^ 
//  Internal compiler error: Unexpected struct declaration found.
//  Please file an issue on the repository and include the code that triggered this error.
    
    impl S {
        const C: u8 = 1;
    }
}

fn main() {
    a();
}
@ironcev ironcev added bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen team:compiler Compiler Team labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team
Projects
None yet
Development

No branches or pull requests

1 participant