Skip to content

Compiler panic in HLIR match compilation: unwrap() on None for wrong-arity enum pattern in or-pattern with literal #25825

@jubnzv

Description

@jubnzv

The compiler panics with called Option::unwrap() on a None value in hlir/match_compilation.rs:186 when compiling a match expression that uses a no-field enum variant with field-destructuring patterns, combined with a literal pattern and a guard.

MRE:

module 0x42::m {
    public enum E<T> has drop {
        A,
        C(T, T, T),
    }

    fun t(): u64 {
        let subject = E::A(0);
        match (subject) {
            E::A(x) if (true) => x,
            E::A(x) | E::C(x, _, 0) => x,
            _ => 1,
        }
    }
}

Reproduce steps:

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

Expected behavior: error message about wrong pattern arity without panic

Git commit: fc75182
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