Skip to content

Fix matching on Int[N] and UInt[N] in match statements.#769

Merged
arshajii merged 1 commit intoexaloop:developfrom
ghuls:fix_match_intn_and_uintn
Mar 24, 2026
Merged

Fix matching on Int[N] and UInt[N] in match statements.#769
arshajii merged 1 commit intoexaloop:developfrom
ghuls:fix_match_intn_and_uintn

Conversation

@ghuls
Copy link
Copy Markdown
Contributor

@ghuls ghuls commented Mar 6, 2026

Fixes: #754

@ghuls ghuls requested review from arshajii and inumanag as code owners March 6, 2026 10:36
@cla-bot cla-bot bot added the cla-signed label Mar 6, 2026
@arshajii
Copy link
Copy Markdown
Contributor

Thanks for this PR, @ghuls. Could you please add a test for this? For convenience, I've written one below; you can paste this at the end of test/core/arithmetic.codon. Then I'll go ahead and merge!

@test
def test_int_match():
    n = 0
    match 42:
        case 0:
            n = 1
        case 42:
            n = 2
        case 100:
            n = 3
        case _:
            n = 4
    assert n == 2

    n = 0
    match u32(42):
        case u32(0):
            n = 1
        case u32(42):
            n = 2
        case u32(100):
            n = 3
        case _:
            n = 4
    assert n == 2

    n = 0
    match u32(99):
        case u32(0):
            n = 1
        case u32(42):
            n = 2
        case u32(100):
            n = 3
        case _:
            n = 4
    assert n == 4

    n = 0
    match i32(42):
        case i32(0):
            n = 1
        case i32(42):
            n = 2
        case i32(100):
            n = 3
        case _:
            n = 4
    assert n == 2

    n = 0
    match i32(99):
        case i32(0):
            n = 1
        case i32(42):
            n = 2
        case i32(100):
            n = 3
        case _:
            n = 4
    assert n == 4

test_int_match()

@ghuls ghuls force-pushed the fix_match_intn_and_uintn branch from 30cd2c9 to 66332f0 Compare March 24, 2026 09:13
@ghuls
Copy link
Copy Markdown
Contributor Author

ghuls commented Mar 24, 2026

@arshajii Added.

@arshajii
Copy link
Copy Markdown
Contributor

Awesome, thanks! Merging now.

@arshajii arshajii merged commit 6dd11c5 into exaloop:develop Mar 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serious bug: matching Int[N] using match/case does not work

2 participants