aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorJonathan Marler <jonathan.j.marler@hp.com>2019-08-23 09:33:33 -0600
committerJonathan Marler <johnnymarler@gmail.com>2019-09-03 22:50:29 -0600
commitb728cb6d4e882592129eef2e37f8fcd8fda78822 (patch)
tree9929bf826b52e9c29dfaa8c8eee930504d788a3f /test/compile_errors.zig
parent77a5f888be664f9ef09e2c93f52338448e992e00 (diff)
downloadzig-b728cb6d4e882592129eef2e37f8fcd8fda78822.tar.gz
zig-b728cb6d4e882592129eef2e37f8fcd8fda78822.zip
Add @Type builtin
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig52
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 {