authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-09 15:32:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-09 15:35:13-07:00
log83bb3d1ad692127cd51c101b6a01fc853ab72990
treeb7a8c22eeb3dcbf252dec787b9437b9aee117dbb
parent2aa4a32097392c869fe2ef58f372a960c0268859

Sema: fix generic fn instantiation with anytype

When the anytype parameter had only one-possible-value (e.g. `void`), it would create a mismatch in the function type and the function call. Now the function type and the callsite both omit the one-possible-value anytype parameter in instantiated generic functions.

3 files changed, 9 insertions(+), 2 deletions(-)

src/Sema.zig+3
......@@ -6158,6 +6158,9 @@ fn zirParamAnytype(
61586158 // function type of the function instruction in this block.
61596159 return;
61606160 }
6161 if (null != try sema.typeHasOnePossibleValue(block, src, param_ty)) {
6162 return;
6163 }
61616164 // The map is already populated but we do need to add a runtime parameter.
61626165 try block.params.append(sema.gpa, .{
61636166 .ty = param_ty,
test/behavior/translate_c_macros.zig+1-1
......@@ -39,7 +39,7 @@ test "reference to a struct type" {
3939}
4040
4141test "cast negative integer to pointer" {
42 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
42 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
4343
4444 try expectEqual(@intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED);
4545}
test/behavior/tuple.zig+5-1
......@@ -50,7 +50,11 @@ test "tuple multiplication" {
5050}
5151
5252test "more tuple concatenation" {
53 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
53 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
54 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
55 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
56 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
57 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
5458
5559 const T = struct {
5660 fn consume_tuple(tuple: anytype, len: usize) !void {