diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-24 19:36:36 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-24 19:36:36 -0700 |
| commit | bb0e28a54ff60581c30156707eeeba1a6bd2b28f (patch) | |
| tree | f7a1fd645bff8dedf1c95f38b22ab706aa6b7fe2 /test/behavior | |
| parent | 7cfa97aa4ee9eb49d97d7d3b88488387bf6d175f (diff) | |
| download | zig-bb0e28a54ff60581c30156707eeeba1a6bd2b28f.tar.gz zig-bb0e28a54ff60581c30156707eeeba1a6bd2b28f.zip | |
Sema: fix generic function with void parameters
This also fixes a bug that I didn't see causing any problems yet in
generic function instantiation where it would read from a GetOrPutResult
too late.
Also it delays full resolution of generic function type parameters until
after the function body is finished being analyzed.
closes #11291
Diffstat (limited to 'test/behavior')
| -rw-r--r-- | test/behavior/generics.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/behavior/generics.zig b/test/behavior/generics.zig index 767c2f3ee3..867cf940b8 100644 --- a/test/behavior/generics.zig +++ b/test/behavior/generics.zig @@ -277,3 +277,16 @@ test "generic function instantiation turns into comptime call" { }; try S.doTheTest(); } + +test "generic function with void and comptime parameter" { + const S = struct { x: i32 }; + const namespace = struct { + fn foo(v: void, s: *S, comptime T: type) !void { + _ = @as(void, v); + try expect(s.x == 1234); + try expect(T == u8); + } + }; + var s: S = .{ .x = 1234 }; + try namespace.foo({}, &s, u8); +} |
