diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 15:58:27 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 19:20:19 -0700 |
| commit | 8b05205bb71fca55569a9ff4cab89ec9e09640ba (patch) | |
| tree | 1bcc329a4a2d79b35f6ab5b6e8e6fcf8bc986f72 /test/cases/compile_errors | |
| parent | e89bfedd8d68a731cb227327a325e16fc7812df9 (diff) | |
| download | zig-8b05205bb71fca55569a9ff4cab89ec9e09640ba.tar.gz zig-8b05205bb71fca55569a9ff4cab89ec9e09640ba.zip | |
implement error for unbounded for loops
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/for.zig | 10 | ||||
| -rw-r--r-- | test/cases/compile_errors/for_unbounded.zig | 11 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test/cases/compile_errors/for.zig b/test/cases/compile_errors/for.zig index dff46af085..5bd3aa0c64 100644 --- a/test/cases/compile_errors/for.zig +++ b/test/cases/compile_errors/for.zig @@ -16,6 +16,13 @@ export fn c() void { _ = byte; } } +export fn d() void { + const x: [*]const u8 = "hello"; + const y: [*]const u8 = "world"; + for (x, 0.., y) |x1, x2, x3| { + _ = x1; _ = x2; _ = x3; + } +} // error // backend=stage2 @@ -28,3 +35,6 @@ export fn c() void { // :9:14: note: for loop operand must be an array, slice, tuple, or vector // :15:16: error: pointer capture of non pointer type '[10]u8' // :15:10: note: consider using '&' here +// :22:5: error: unbounded for loop +// :22:10: note: type '[*]const u8' has no upper bound +// :22:18: note: type '[*]const u8' has no upper bound diff --git a/test/cases/compile_errors/for_unbounded.zig b/test/cases/compile_errors/for_unbounded.zig new file mode 100644 index 0000000000..5d05b1061f --- /dev/null +++ b/test/cases/compile_errors/for_unbounded.zig @@ -0,0 +1,11 @@ +export fn b() void { + for (0..) |i| { + _ = i; + } +} + +// error +// backend=stage2 +// target=native +// +// :2:5: error: unbounded for loop |
