The compiler panics with internal error: entered unreachable code in src/sema/statements.rs:2358 when a try statement is applied to a new expression whose operand, after stripping the ok-block FunctionCallBlock, is not a FunctionCall / NamedFunctionCall (e.g. a bare identifier).
MRE:
contract C {
function f() public {
try new X {} catch {}
}
}
contract X {}
Reproduce: save as mre.sol, run solang compile --target polkadot mre.sol.
Output:
thread 'main' panicked at src/sema/statements.rs:2358:22:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expected behavior: sema emits a diagnostic such as "try only supports external calls or constructor calls" (matching the neighbouring non-new arm) and aborts resolution cleanly.
Also reproduces on --target soroban and --target evm. Solana rejects try earlier, so it is not affected.
Git commit: 901bfb9
Build: release
rustc 1.96.0-nightly (562dee482 2026-03-21)
The compiler panics with
internal error: entered unreachable codeinsrc/sema/statements.rs:2358when atrystatement is applied to anewexpression whose operand, after stripping the ok-blockFunctionCallBlock, is not aFunctionCall/NamedFunctionCall(e.g. a bare identifier).MRE:
Reproduce: save as
mre.sol, runsolang compile --target polkadot mre.sol.Output:
Expected behavior: sema emits a diagnostic such as
"try only supports external calls or constructor calls"(matching the neighbouring non-newarm) and aborts resolution cleanly.Also reproduces on
--target sorobanand--target evm. Solana rejectstryearlier, so it is not affected.Git commit: 901bfb9
Build: release
rustc 1.96.0-nightly (562dee482 2026-03-21)