diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-02-18 15:34:22 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-02-18 15:34:22 -0500 |
| commit | 662996e4a8826f62f76bdafdb7ccbb1d52210c96 (patch) | |
| tree | c0397d9b09c6dd66bd828c4162b8439bc03ec304 /test | |
| parent | e8a84927ab989d3c8fb6668dd242ada0a8f99585 (diff) | |
| parent | d056c7732b87633ace03dd15668a88eac76b62a5 (diff) | |
| download | zig-662996e4a8826f62f76bdafdb7ccbb1d52210c96.tar.gz zig-662996e4a8826f62f76bdafdb7ccbb1d52210c96.zip | |
Merge branch 'FireFox317-lazy-typeinfo-decls'
Closes #4435
Closes #3893
Closes #2584
Diffstat (limited to 'test')
| -rw-r--r-- | test/compile_errors.zig | 23 | ||||
| -rw-r--r-- | test/stage1/behavior/type_info.zig | 11 |
2 files changed, 14 insertions, 20 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index cc2863a046..240980efba 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -30,10 +30,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void'", }); - cases.addTest("dependency loop in top-level decl with @TypeInfo", - \\export const foo = @typeInfo(@This()); + cases.addTest("dependency loop in top-level decl with @TypeInfo when accessing the decls", + \\export const foo = @typeInfo(@This()).Struct.decls; , &[_][]const u8{ "tmp.zig:1:20: error: dependency loop detected", + "tmp.zig:1:45: note: referenced here", }); cases.add("function call assigned to incorrect type", @@ -1346,24 +1347,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:8:28: note: referenced here", }); - cases.add("@typeInfo causing depend on itself compile error", - \\const start = struct { - \\ fn crash() bug() { - \\ return bug; - \\ } - \\}; - \\fn bug() void { - \\ _ = @typeInfo(start).Struct; - \\} - \\export fn entry() void { - \\ var boom = start.crash(); - \\} - , &[_][]const u8{ - "tmp.zig:7:9: error: dependency loop detected", - "tmp.zig:2:19: note: referenced here", - "tmp.zig:10:21: note: referenced here", - }); - cases.add("enum field value references enum", \\pub const Foo = extern enum { \\ A = Foo.B, diff --git a/test/stage1/behavior/type_info.zig b/test/stage1/behavior/type_info.zig index 9d577ec0b4..a3988cba6d 100644 --- a/test/stage1/behavior/type_info.zig +++ b/test/stage1/behavior/type_info.zig @@ -375,3 +375,14 @@ test "sentinel of opaque pointer type" { const c_void_info = @typeInfo(*c_void); expect(c_void_info.Pointer.sentinel == null); } + +test "@typeInfo does not force declarations into existence" { + const S = struct { + x: i32, + + fn doNotReferenceMe() void { + @compileError("test failed"); + } + }; + comptime expect(@typeInfo(S).Struct.fields.len == 1); +} |
