zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 83bb3d1ad692127cd51c101b6a01fc853ab72990 (tree)
parent 2aa4a32097392c869fe2ef58f372a960c0268859
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed,  9 Mar 2022 15:32:12 -0700

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.

Diffstat:
Msrc/Sema.zig | 3+++
Mtest/behavior/translate_c_macros.zig | 2+-
Mtest/behavior/tuple.zig | 6+++++-
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -6158,6 +6158,9 @@ fn zirParamAnytype( // function type of the function instruction in this block. return; } + if (null != try sema.typeHasOnePossibleValue(block, src, param_ty)) { + return; + } // The map is already populated but we do need to add a runtime parameter. try block.params.append(sema.gpa, .{ .ty = param_ty, diff --git a/test/behavior/translate_c_macros.zig b/test/behavior/translate_c_macros.zig @@ -39,7 +39,7 @@ test "reference to a struct type" { } test "cast negative integer to pointer" { - if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO try expectEqual(@intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED); } diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig @@ -50,7 +50,11 @@ test "tuple multiplication" { } test "more tuple concatenation" { - if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO const T = struct { fn consume_tuple(tuple: anytype, len: usize) !void {