diff options
| author | David Rubin <87927264+Rexicon226@users.noreply.github.com> | 2024-02-03 11:16:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-03 19:16:27 +0000 |
| commit | eb4024036d3e8e0c4a8b0dcf09da107421f3fa01 (patch) | |
| tree | 6694d3bb97fa0aaec6e947536263ce78f60e72af /test | |
| parent | f2e249e92020462ac29f34fc3d45cef3dc90a3b2 (diff) | |
| download | zig-eb4024036d3e8e0c4a8b0dcf09da107421f3fa01.tar.gz zig-eb4024036d3e8e0c4a8b0dcf09da107421f3fa01.zip | |
Add error hint when looping over `ErrorUnion`
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/compile_errors/for_loop_error_union.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/cases/compile_errors/for_loop_error_union.zig b/test/cases/compile_errors/for_loop_error_union.zig new file mode 100644 index 0000000000..d7a8d1952e --- /dev/null +++ b/test/cases/compile_errors/for_loop_error_union.zig @@ -0,0 +1,15 @@ +fn b() !u32 { + return 2; +} + +export fn a() void { + for (b()) |_| {} +} + +// error +// backend=stage2 +// target=native +// +// :6:11: error: type '@typeInfo(@typeInfo(@TypeOf(tmp.b)).Fn.return_type.?).ErrorUnion.error_set!u32' is not indexable and not a range +// :6:11: note: for loop operand must be a range, array, slice, tuple, or vector +// :6:11: note: consider using 'try', 'catch', or 'if' |
