Files
zig/test/behavior
David Rubin aa2b178029 disallow switch case capture discards
Previously Zig allowed you to write something like,
```zig
switch (x) {
    .y => |_| {
```

This seems a bit strange because in other cases, such as when
capturing the tag in a switch case,
```zig
switch (x) {
    .y => |_, _| {
```
this produces an error.

The only usecase I can think of for the previous behaviour is
if you wanted to assert that all union payloads are able
to coerce,
```zig
const X = union(enum) { y: u8, z: f32 };

switch (x) {
    .y, .z => |_| {
```

This will compile-error with the `|_|` and pass without it.

I don't believe this usecase is strong enough to keep the current
behaviour; it was never used in the Zig codebase and I cannot
find a single usage of this behaviour in the real world, searching
through Sourcegraph.
2026-01-11 11:37:16 +00:00
..
2025-11-22 22:42:38 +00:00
2025-09-20 18:33:00 -07:00
2025-06-16 13:22:19 +03:30
2025-11-22 22:42:38 +00:00
2025-11-22 22:42:38 +00:00
2025-06-16 13:22:19 +03:30
2025-06-16 13:22:19 +03:30
2025-11-22 22:42:38 +00:00
2024-05-11 02:17:24 -07:00
2025-06-16 13:22:19 +03:30
2024-06-13 02:20:47 -07:00
2025-12-07 07:21:15 +01:00
2025-11-22 22:42:38 +00:00
2025-11-22 22:42:38 +00:00
2025-09-20 18:33:00 -07:00
2025-06-16 13:22:19 +03:30
2025-06-16 13:22:19 +03:30
2025-06-16 13:22:19 +03:30
2025-11-22 22:42:38 +00:00
2025-09-20 18:33:01 -07:00
2025-11-22 22:42:38 +00:00
2024-06-13 02:20:47 -07:00
2025-12-07 07:21:15 +01:00
2025-07-27 08:01:07 -04:00