mirror of
https://github.com/ziglang/zig.git
synced 2026-02-18 15:31:48 +00:00
Sema: do not emit generic poison for non generic parameters
Closes #12679
This commit is contained in:
parent
67a44211f7
commit
01d19a8d3c
18
src/Sema.zig
18
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(
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
export fn entry() void {
|
||||
const llamas1 = makeLlamas(5);
|
||||
const llamas2 = makeLlamas(5);
|
||||
_ = llamas1;
|
||||
_ = llamas2;
|
||||
}
|
||||
|
||||
fn makeLlamas(count: usize) [count]u8 {
|
||||
_ = count;
|
||||
}
|
||||
|
||||
// error
|
||||
// target=native
|
||||
//
|
||||
// :8:30: error: unable to resolve comptime value
|
||||
// :8:30: note: array length must be comptime known
|
||||
Loading…
x
Reference in New Issue
Block a user