ITADN

Discarding first inline else capture on tagged union switch when using labeled switch fails to compile

#26038OpenCassunshine 创建于 2025-11-24
bug
C
Cassunshinecommented
### Zig Version 0.15.2 ### Steps to Reproduce and Observed Behavior Sorry for the bulky issue name :< The bug is just kinda that specific. ```zig const TaggedUnion = union(enum) { a: u32, b: i32, c: void, }; // In some function... const tu: TaggedUnion = .{ .a = 15 }; sw: switch (tu) { inline else => |_, tag| { // Code body doesn't matter, but presumably you're using tag somewhere. _ = tag; continue :sw next; // Any continue value still fails }, } ``` The code above will fail to compile with no sensible error (only returning error code 1), despite the fact that this should be valid as far as I can tell. Replacing `inline else => |_, tag|` with `inline else => |value, tag|` and then discarding `value` using `_ = value` compiles just fine. I don't personally see any use cases where this would actually matter, but it definitely shouldn't just crash without explanation like it does. ### Expected Behavior The given code should compile, *or* if it's not valid for some reason, it should return an actual compiler error instead of simply crashing the compiler.
4 条评论