The compiler panics with called Option::unwrap() on a None value in src/sema/expression/function_call.rs:2227 when a state-variable initializer contains an external function call (e.g. uint public x = this.foo();). The Solana-target "accounts are required" check unconditionally unwraps context.function_no, but state-variable initializers are resolved at file scope where function_no is None.
MRE:
contract C {
uint public x = this.foo();
function foo() external pure returns (uint) { return 1; }
}
Reproduce: save as mre.sol, run solang compile --target solana mre.sol.
Output:
thread 'main' panicked at src/sema/expression/function_call.rs:2227:50:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expected behavior: sema either rejects external calls in state-variable initializers with a proper diagnostic, or handles the context.function_no == None case in the Solana accounts-required check without unwrapping.
Solana-specific: the crash site lives inside if ns.target == Target::Solana { ... }. Other targets do not hit this path.
Git commit: 901bfb9
Build: release
rustc 1.96.0-nightly (562dee482 2026-03-21)
The compiler panics with
called Option::unwrap() on a None valueinsrc/sema/expression/function_call.rs:2227when a state-variable initializer contains an external function call (e.g.uint public x = this.foo();). The Solana-target "accounts are required" check unconditionally unwrapscontext.function_no, but state-variable initializers are resolved at file scope wherefunction_noisNone.MRE:
Reproduce: save as
mre.sol, runsolang compile --target solana mre.sol.Output:
Expected behavior:
semaeither rejects external calls in state-variable initializers with a proper diagnostic, or handles thecontext.function_no == Nonecase in the Solana accounts-required check without unwrapping.Solana-specific: the crash site lives inside
if ns.target == Target::Solana { ... }. Other targets do not hit this path.Git commit: 901bfb9
Build: release
rustc 1.96.0-nightly (562dee482 2026-03-21)