diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-25 17:08:55 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-07-25 17:08:55 -0400 |
| commit | 84195467ad974f9b7201e4e1bbd6dccbd5e7ab90 (patch) | |
| tree | 4f7f0a4c239b5fbbd85bb6be5588db8179898802 /test/compile_errors.zig | |
| parent | 2257660916a8c92d953a5a71da6c2d4f7cc031e6 (diff) | |
| download | zig-84195467ad974f9b7201e4e1bbd6dccbd5e7ab90.tar.gz zig-84195467ad974f9b7201e4e1bbd6dccbd5e7ab90.zip | |
add compile error for non-inline for loop on comptime type
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index b7bd39f29e..91693e091c 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,20 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add( + "non-inline for loop on a type that requires comptime", + \\const Foo = struct { + \\ name: []const u8, + \\ T: type, + \\}; + \\export fn entry() void { + \\ const xx: [2]Foo = undefined; + \\ for (xx) |f| {} + \\} + , + ".tmp_source.zig:7:15: error: variable of type 'Foo' must be const or comptime", + ); + + cases.add( "generic fn as parameter without comptime keyword", \\fn f(_: fn (var) void) void {} \\fn g(_: var) void {} |
