Skip to content

Exhaustive pattern matches on numeric values yield compiler warning #6928

@teo-tsirpanis

Description

@teo-tsirpanis

I created a function to compute the AES S-Box. This is its code:

    let sBox k =
        match k with
        | 0uy ->  0x63uy
        | 1uy ->  0x7cuy
        | 2uy ->  0x77uy
        | 3uy ->  0x7buy
       /// It lasts forever...
        | 251uy ->  0x0fuy
        | 252uy ->  0xb0uy
        | 253uy ->  0x54uy
        | 254uy ->  0xbbuy
        | 255uy ->  0x16uy

However, the compiler raises an "Incomplete pattern matches on this expression" warning, even though my code handles all 256 possible cases for the byte type.

Repro steps

Already covered.

Expected behavior

Code compiles successfuly without warnings.

Actual behavior

image

Known workarounds

Have a redundant wildcard case at the end of match statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions