Compiler panics if an ABI associated const is not initialized in the ABI
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
When compiling the below code, the compiler will panic with:
```
thread 'main' panicked at sway-core/src/ir_generation/function.rs:3216:13:
internal error: entered unreachable code: cannot compile const declaration without an expression
```
```
contract;
abi A {
const ID: u32;
fn foo() -> u32;
}
impl A for Contract {
const ID: u32 = 1;
fn foo() -> u32 {
Self::ID
}
}
#[test]
fn test() {
let a = abi(A, CONTRACT_ID);
assert_eq(1, a.foo());
}
```
Note that we have the [`associated_const_abi` test](https://github.com/FuelLabs/sway/blob/893e59f632f1d7d319080ba1a9d4cfc523ab0212/test/src/e2e_vm_tests/test_programs/should_pass/language/associated_const_abi/src/main.sw#L4) that has an uninitialized associated constant `ID`, but unfortunately the test did not call any functions that use `ID` and therefore it compiled and run without issues.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.