diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-04 22:46:05 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-04 22:46:05 -0700 |
| commit | 95a87e88fac3fc563ac3baaf4eb8027341f4131e (patch) | |
| tree | 4b028355d7f38451d7de1cc2977aa59b9543c8f3 /src/Sema.zig | |
| parent | 51ef31a8331e92103253a37ddfdacbd263cee81d (diff) | |
| download | zig-95a87e88fac3fc563ac3baaf4eb8027341f4131e.tar.gz zig-95a87e88fac3fc563ac3baaf4eb8027341f4131e.zip | |
Sema: forward switch condition to captures
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 1430e80ac0..b1267e195f 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -7273,9 +7273,14 @@ fn zirSwitchCapture( } }, else => { - return sema.fail(block, operand_src, "switch on type '{}' provides no capture value", .{ - operand_ty.fmt(target), - }); + // In this case the capture value is just the passed-through value of the + // switch condition. + if (is_ref) { + assert(operand_is_ref); + return operand_ptr; + } else { + return operand; + } }, } } |
