Skip to content

Fix segfault in list pattern match #7986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2025
Merged

Conversation

rtfeldman
Copy link
Contributor

Claude fixed this (Zed Agent) with one prompt:

in the new Zig compiler, this works:
```
module [last]

last = |l|
    match l {
        [.., e] => Ok(e)
        [] => Err(EmptyList)
    }
```

this works too:

```
module [last]

last = |l|
    match l {
        _ => Err(EmptyList)
        [.., e] => Ok(e)
    }
```

however, this segfaults:

```
module [last]

last = |l|
    match l {
        [] => Err(EmptyList)
        [.., e] => Ok(e)
    }
```

please reproduce in a `zig build test` test somewhere (none of the 3 should segfault!) and then fix the segfault. please add it to an existing test file; don't create a new one for this.

@lukewilliamboswell lukewilliamboswell merged commit 7940add into main Jul 9, 2025
24 checks passed
@lukewilliamboswell lukewilliamboswell deleted the fix-list-segfault branch July 9, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants