diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-08-30 14:40:48 +0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-08-30 12:22:07 -0700 |
| commit | 01d19a8d3cdd52ad50f45bfb8666b56ccf8d3a22 (patch) | |
| tree | 777dff34489b8bb15e25aed80ff802cb88018c3c /src | |
| parent | 67a44211f7a442d33096cc0dfff059eee9315bc6 (diff) | |
| download | zig-01d19a8d3cdd52ad50f45bfb8666b56ccf8d3a22.tar.gz zig-01d19a8d3cdd52ad50f45bfb8666b56ccf8d3a22.zip | |
Sema: do not emit generic poison for non generic parameters
Closes #12679
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 823ae9baf2..bf147a7cb4 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -8195,8 +8195,22 @@ fn zirParam( .is_comptime = comptime_syntax, .name = param_name, }); - const result = try sema.addConstant(param_ty, Value.initTag(.generic_poison)); - try sema.inst_map.putNoClobber(sema.gpa, inst, result); + + if (is_comptime) { + // If this is a comptime parameter we can add a constant generic_poison + // since this is also a generic parameter. + const result = try sema.addConstant(param_ty, Value.initTag(.generic_poison)); + try sema.inst_map.putNoClobber(sema.gpa, inst, result); + } else { + // Otherwise we need a dummy runtime instruction. + const result_index = @intCast(Air.Inst.Index, sema.air_instructions.len); + try sema.air_instructions.append(sema.gpa, .{ + .tag = .alloc, + .data = .{ .ty = param_ty }, + }); + const result = Air.indexToRef(result_index); + try sema.inst_map.putNoClobber(sema.gpa, inst, result); + } } fn zirParamAnytype( |
