FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.58k stars 5.37k forks source link

Compiler panics when an associated constant is recursively initialized to a const-eval module function #6539

Open ironcev opened 2 months ago

ironcev commented 2 months ago

When an associated constant is recursively initialized to a const-eval module function like in the below example, instead of emitting an error, compiler panics 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 mod_fn() -> u8 {
    S::S_ASSOC
}

impl S {
    const S_ASSOC: u8 = mod_fn();
}

When fixing this issue, enable and adjust the recursive_const_associated_over_module_function test which is linked to this issue via GitHub link in the test TODO.