这是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