diff options
| author | Jonathan Marler <jonathan.j.marler@hp.com> | 2019-08-23 09:33:33 -0600 |
|---|---|---|
| committer | Jonathan Marler <johnnymarler@gmail.com> | 2019-09-03 22:50:29 -0600 |
| commit | b728cb6d4e882592129eef2e37f8fcd8fda78822 (patch) | |
| tree | 9929bf826b52e9c29dfaa8c8eee930504d788a3f /test/compile_errors.zig | |
| parent | 77a5f888be664f9ef09e2c93f52338448e992e00 (diff) | |
| download | zig-b728cb6d4e882592129eef2e37f8fcd8fda78822.tar.gz zig-b728cb6d4e882592129eef2e37f8fcd8fda78822.zip | |
Add @Type builtin
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 871ff63e23..1438a59539 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,58 @@ const tests = @import("tests.zig"); const builtin = @import("builtin"); pub fn addCases(cases: *tests.CompileErrorContext) void { + + cases.add( + "wrong type for @Type", + \\export fn entry() void { + \\ _ = @Type(0); + \\} + , + "tmp.zig:2:15: error: expected type 'builtin.TypeInfo', found 'comptime_int'", + ); + + cases.add( + "@Type with non-constant expression", + \\const builtin = @import("builtin"); + \\var globalTypeInfo : builtin.TypeInfo = undefined; + \\export fn entry() void { + \\ _ = @Type(globalTypeInfo); + \\} + , + "tmp.zig:4:15: error: unable to evaluate constant expression", + ); + + cases.add( + "@Type with TypeInfo.Int", + \\const builtin = @import("builtin"); + \\export fn entry() void { + \\ _ = @Type(builtin.TypeInfo.Int { + \\ .is_signed = true, + \\ .bits = 8, + \\ }); + \\} + , + "tmp.zig:3:36: error: expected type 'builtin.TypeInfo', found 'builtin.Int'", + ); + + cases.add( + "Struct unavailable for @Type", + \\export fn entry() void { + \\ _ = @Type(@typeInfo(struct { })); + \\} + , + "tmp.zig:2:15: error: @Type not availble for 'TypeInfo.Struct'", + ); + + cases.add( + "array not implemented for @Type", + \\export fn entry() void { + \\ _ = @Type(@typeInfo(enum{x})); + \\} + , + "tmp.zig:2:15: error: TODO implement @Type forr 'TypeInfo.Enum': see https://github.com/ziglang/zig/issues/2907", + ); + cases.add( "wrong type for result ptr to @asyncCall", \\export fn entry() void { |
