Skip to content

Compiler panic in cfgir/locals/state.rs: missing local state for __match_tmp%#const_guard in match with constant pattern and guarded @ binding #25790

@jubnzv

Description

@jubnzv

The compiler panics with ICE: Unable to get state for local Var("__match_tmp%#const_guard#...") in cfgir/locals/state.rs:74 when compiling a match expression on a scalar value that combines a constant pattern arm with a guarded @-binding arm.

Both are required to trigger:

  • A constant pattern arm (e.g. MY_CONST => ...)
  • A guarded arm with @ binding (e.g. y @ _ if (*y > 0) => ...)

MRE:

module 0x2a::M {
    const MY_CONST: u64 = 60;

    public fun f(): u64 {
        match (0u64) {
            MY_CONST => 1u64,
            y @ _ if (*y > 0) => 2u64,
            _ => 3u64
        }
    }
}

Reproduce steps:

cd external-crates/move
cargo +nightly run --release -p move-compiler --bin move-check -- mre.move

Output:

thread 'main' panicked at crates/move-compiler/src/cfgir/locals/state.rs:74:32:
ICE: Unable to get state for local Var(
    "__match_tmp%#const_guard#2#2#0",
)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior: successful compilation. The program is valid Move code and should compile without errors.

Git commit: dc73efd
Build: release
cargo 1.91.0-nightly (840b83a10 2025-07-30)
rustc 1.91.0-nightly (3672a55b7 2025-08-13)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions