sway
sway copied to clipboard
Compiler panics when an associated constant is initialized to a const-eval associated function
When an associated constant is initialized to a const-eval associated function like in the below example, 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 {}
impl S {
fn bar() -> u8 {
0
}
}
impl S {
const S_ASSOC: u8 = Self::bar();
}
Panicking is also there if it is initialized with S::bar().
When fixing this issue, adjust the associated_const_in_decls_of_other_constants test which is linked to this issue via GitHub link in the test TODO.