θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content

[Bug] Allow using _ to match a tupleΒ #16765

@vineethk

Description

@vineethk

πŸ› Bug

Consider the following code:

module 0xc0ffee::m {
    enum X has copy, drop {
        A,
        B
    }

    fun test(x: X): u64 {
        match ((x, x)) {
            (X::A, X::A) => 1,
            _ => 2, // note: (_, _) works
        }
    }
}

This fails compilation with the error message:

 error: tuple type `(X, X)` is not allowed as a type argument
   β”Œβ”€ TEMPFILE:10:13
   β”‚
10 β”‚             _ => 2,
   β”‚             ^

However, we should let the compiler compile this without any errors (because _ is supposed to be a catch all), similar to Rust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler-v2stale-exemptPrevents issues from being automatically marked and closed as stalestarter-task

    Type

    Projects

    Status

    For Grabs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions