aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/ir.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-12-29 12:58:47 +0100
committerLemonBoy <thatlemon@gmail.com>2020-12-30 09:42:20 +0100
commit88634f0481fb1bd78f8d018b76cab6590691c8a9 (patch)
tree68f4e1cc2f26f176de68c880e83b8f2484165928 /src/stage1/ir.cpp
parent3634d44d08c73326c7783cf2a3095acb50eb2e1c (diff)
downloadzig-88634f0481fb1bd78f8d018b76cab6590691c8a9.tar.gz
zig-88634f0481fb1bd78f8d018b76cab6590691c8a9.zip
stage1: Allow variable capture for multi-prong switch arms
Handle the multi-prong case as we do with range cases. Closes #7188
Diffstat (limited to 'src/stage1/ir.cpp')
-rw-r--r--src/stage1/ir.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp
index d3ed3cfaab..edda765ff9 100644
--- a/src/stage1/ir.cpp
+++ b/src/stage1/ir.cpp
@@ -24207,6 +24207,8 @@ static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwi
ref_type->data.pointer.allow_zero);
return ir_analyze_ptr_cast(ira, &instruction->base.base, target_value_ptr,
&instruction->target_value_ptr->base, new_target_value_ptr_type, &instruction->base.base, false, false);
+ } else if (instruction->prongs_len > 1) {
+ return target_value_ptr;
} else {
ir_add_error(ira, &instruction->base.base,
buf_sprintf("switch on type '%s' provides no expression parameter", buf_ptr(&target_type->name)));