authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-05-18 19:28:26+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-05-18 19:28:26+03:00
log75a4c02880393c08e245c80ed6114e97e2c47a25
tree33da3518f431b9e1437be67382052c95e7ce8b67
parent400a91e1c644228a66aa1702b9d800f018712105

Updated test


2 files changed, 23 insertions(+), 1 deletions(-)

test/stage1/behavior.zig+1-1
......@@ -40,7 +40,7 @@ comptime {
4040 _ = @import("behavior/bugs/3384.zig");
4141 _ = @import("behavior/bugs/3586.zig");
4242 _ = @import("behavior/bugs/3742.zig");
43 _ = @import("behavior/bugs/4328.zig");
43 _ = @import("behavior/bugs/4328_5305.zig");
4444 _ = @import("behavior/bugs/4560.zig");
4545 _ = @import("behavior/bugs/4769_a.zig");
4646 _ = @import("behavior/bugs/4769_b.zig");
test/stage1/behavior/bugs/4328_5305.zig+22
......@@ -3,9 +3,11 @@ const expectEqual = @import("std").testing.expectEqual;
33const FILE = extern struct {
44 dummy_field: u8,
55};
6
67extern fn printf([*c]const u8, ...) c_int;
78extern fn fputs([*c]const u8, noalias [*c]FILE) c_int;
89extern fn ftell([*c]FILE) c_long;
10extern fn fopen([*c]const u8, [*c]const u8) [*c]FILE;
911
1012const S = extern struct {
1113 state: c_short,
......@@ -47,3 +49,23 @@ test "Peer resolution of extern function calls in @TypeOf" {
4749 Test.doTheTest();
4850 comptime Test.doTheTest();
4951}
52
53test "Extern function calls, dereferences and field access in @TypeOf" {
54 const Test = struct {
55 fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) {
56 return .{ .dummy_field = 0 };
57 }
58
59 fn test_fn_2(a: var) @TypeOf(fopen("test", "r").*.dummy_field) {
60 return 255;
61 }
62
63 fn doTheTest() void {
64 expectEqual(FILE, @TypeOf(test_fn_1(0)));
65 expectEqual(u8, @TypeOf(test_fn_2(0)));
66 }
67 };
68
69 Test.doTheTest();
70 comptime Test.doTheTest();
71}
\ No newline at end of file