diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-05-31 15:19:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-31 15:19:25 -0400 |
| commit | d09d61be979fc97233bd53d9d082a86e4dcd9779 (patch) | |
| tree | 502e0476e43e1a8ea0e0dd9e48e9fb8f76d1dd7c /test/behavior | |
| parent | d410693dadfe791e616e78239fa0cec707b95cfa (diff) | |
| parent | 282437c7538e3e70ce06cfee7affe976de28a780 (diff) | |
| download | zig-d09d61be979fc97233bd53d9d082a86e4dcd9779.tar.gz zig-d09d61be979fc97233bd53d9d082a86e4dcd9779.zip | |
Merge pull request #11762 from Vexu/stage2
Stage2 fixes
Diffstat (limited to 'test/behavior')
| -rw-r--r-- | test/behavior/basic.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index e887a1d4b6..32df664bae 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -977,3 +977,31 @@ test "weird array and tuple initializations" { .b = if (a) .{ .e = .a } else .{ .e = .b }, }; } + +test "array type comes from generic function" { + const S = struct { + fn A() type { + return struct { a: u8 = 0 }; + } + }; + const args = [_]S.A(){.{}}; + _ = args; +} + +test "generic function uses return type of other generic function" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + + const S = struct { + fn call( + f: anytype, + args: anytype, + ) @TypeOf(@call(.{}, f, @as(@TypeOf(args), undefined))) { + return @call(.{}, f, args); + } + + fn func(arg: anytype) @TypeOf(arg) { + return arg; + } + }; + try std.testing.expect(S.call(S.func, .{@as(u8, 1)}) == 1); +} |
