Skip to content

Compiler panics when associated constant is initialized via const eval function #7065

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

Open
ironcev opened this issue Apr 4, 2025 · 0 comments
Labels
bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team

Comments

@ironcev
Copy link
Member

ironcev commented Apr 4, 2025

The below example will panic with:

thread 'main' panicked at sway-core/src/semantic_analysis/type_check_analysis.rs:64:44:
called `Option::unwrap()` on a `None` value
library;

struct S {}

fn eval_s_c(val: u8) -> u8 {
    val
}

impl S {
    const S_C: u8 = eval_s_c(111);
}

Initializing a module constant works fine:

library;

fn eval_s_c(val: u8) -> u8 {
    val
}

const S_C: u8 = eval_s_c(111);
@ironcev ironcev added bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team labels Apr 4, 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 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