diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-04-20 10:57:41 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-04-20 10:57:41 -0400 |
| commit | 599215cee46b83d052f57a3e6566098900332e38 (patch) | |
| tree | 57e57b3864bd8ad3e67c3fe6b85f0a8bf5df3e04 /test/compile_errors.zig | |
| parent | 68f75a3130d09e1cd86caa1252ff3c4f517a452b (diff) | |
| download | zig-599215cee46b83d052f57a3e6566098900332e38.tar.gz zig-599215cee46b83d052f57a3e6566098900332e38.zip | |
add compile error tests for offsetOf builtin
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 16431c76f1..5880eebbf1 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -1565,6 +1565,22 @@ pub fn addCases(cases: &tests.CompileErrorContext) { \\} , ".tmp_source.zig:8:29: error: field 'b' has index 1 but pointer value is index 0 of struct 'Foo'"); + cases.add("@offsetOf - non struct", + \\const Foo = i32; + \\export fn foo() -> usize { + \\ return @offsetOf(Foo, "a"); + \\} + , ".tmp_source.zig:3:22: error: expected struct type, found 'i32'"); + + cases.add("@offsetOf - bad field name", + \\const Foo = struct { + \\ derp: i32, + \\}; + \\export fn foo() -> usize { + \\ return @offsetOf(Foo, "a"); + \\} + , ".tmp_source.zig:5:27: error: struct 'Foo' has no field 'a'"); + cases.addExe("missing main fn in executable", \\ , "error: no member named 'main' in '"); |
