aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-09-04 11:12:24 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-09-04 11:12:24 -0400
commit53a6aea216d7b1e6b6072d30f2d51ed801d9e0f9 (patch)
tree41809dbfec90af3c6320239cd186f9ede7b8b8e1 /test/compile_errors.zig
parent77a5f888be664f9ef09e2c93f52338448e992e00 (diff)
parentac7703f65f7acc9137e28ded97659fbaadea4e66 (diff)
downloadzig-53a6aea216d7b1e6b6072d30f2d51ed801d9e0f9.tar.gz
zig-53a6aea216d7b1e6b6072d30f2d51ed801d9e0f9.zip
Merge branch 'marler8997-typeBuiltin'
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..38fca5754d 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3,6 +3,58 @@ const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "attempt to create 17 bit float type",
+ \\const builtin = @import("builtin");
+ \\comptime {
+ \\ _ = @Type(builtin.TypeInfo { .Float = builtin.TypeInfo.Float { .bits = 17 } });
+ \\}
+ ,
+ "tmp.zig:3:32: error: 17-bit float unsupported",
+ );
+
+ 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(
"wrong type for result ptr to @asyncCall",
\\export fn entry() void {
\\ _ = async amain();