Skip to content

Compiler panic in HLIR pass: assert!(idx == 0) in type_at_index for macro with mismatched return type #25472

@jubnzv

Description

@jubnzv

The compiler panics with assert!(idx == 0) in hlir/ast.rs:825 when a macro with a declared tuple return type has a garbled body that produces a single value.

MRE:

module 0x42::M {
    macro fun f($x: u64): (u64, u64) {
       ($, $x)
    }
    fun test() {
        let (_a, _b) = f!(1);
    }
}

Reproduce steps:

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

Output:

thread 'main' panicked at crates/move-compiler/src/hlir/ast.rs:825:17:
assertion failed: idx == 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior: a diagnostic error about the malformed macro body or type mismatch.

Git commit: 1a27af4
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