Skip to content

Compiler panic in codegen: List and Type Operator shall not appear in the CFG when type(T) is used as a ternary condition #1873

@jubnzv

Description

@jubnzv

The compiler panics with unreachable!("List and Type Operator shall not appear in the CFG") in src/codegen/expression.rs:1237 when a type(T) expression (whose sema type is Type::Void, per src/sema/expression/retrieve_type.rs) is used as the condition of a ternary operator.

MRE:

contract C {
    function f() public returns (int) {
        return type(bool) ? 1 : 2;
    }
}

Reproduce: save as mre.sol, run solang compile --target polkadot mre.sol.

Output:

thread 'main' panicked at src/codegen/expression.rs:1237:13:
internal error: entered unreachable code: List and Type Operator shall not appear in the CFG
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior: sema rejects a type(T) expression used in a value position / boolean context with a proper diagnostic.

Reproduces on all four targets (solana, polkadot, evm, soroban). Related to but distinct from #1865 — a different sentinel variant (Expression::TypeOperator) reaches codegen from the same missing sema check.

Git commit: 901bfb9
Build: release
rustc 1.96.0-nightly (562dee482 2026-03-21)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions