diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-11-06 22:07:19 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-11-06 22:07:19 -0500 |
| commit | 634e8713c394bacfe080d03256d1dd4f9a43dd8c (patch) | |
| tree | 8fa396aa96acfa556217f83eb90ecb6a14d88c4d /test/compile_errors.zig | |
| parent | f0dafd3f209a342f055850108651545bea9b065b (diff) | |
| download | zig-634e8713c394bacfe080d03256d1dd4f9a43dd8c.tar.gz zig-634e8713c394bacfe080d03256d1dd4f9a43dd8c.zip | |
add @memberType and @memberName builtin functions
see #383
there is a plan to unify most of the reflection into 2
builtin functions, as outlined in the above issue,
but this gives us needed features for now, and we can
iterate on the design in future commits
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 6901bd302c..b2bfb9b8e4 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2289,4 +2289,50 @@ pub fn addCases(cases: &tests.CompileErrorContext) { \\fn add(a: i32, b: i32) -> i32 { return a + b; } , ".tmp_source.zig:2:32: error: arg index 2 out of bounds; 'fn(i32, i32) -> i32' has 2 arguments"); + + cases.add("@memberType on unsupported type", + \\comptime { + \\ _ = @memberType(i32, 0); + \\} + , + ".tmp_source.zig:2:21: error: type 'i32' does not support @memberType"); + + cases.add("@memberType struct out of bounds", + \\comptime { + \\ _ = @memberType(Foo, 0); + \\} + \\const Foo = struct {}; + , + ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members"); + + cases.add("@memberType enum out of bounds", + \\comptime { + \\ _ = @memberType(Foo, 0); + \\} + \\const Foo = enum {}; + , + ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members"); + + cases.add("@memberName on unsupported type", + \\comptime { + \\ _ = @memberName(i32, 0); + \\} + , + ".tmp_source.zig:2:21: error: type 'i32' does not support @memberName"); + + cases.add("@memberName struct out of bounds", + \\comptime { + \\ _ = @memberName(Foo, 0); + \\} + \\const Foo = struct {}; + , + ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members"); + + cases.add("@memberName enum out of bounds", + \\comptime { + \\ _ = @memberName(Foo, 0); + \\} + \\const Foo = enum {}; + , + ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members"); } |
