Skip to content

Commit

Permalink
stage2: add error for non-void error union payload being ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexu committed Oct 6, 2022
1 parent 138cb1e commit 8566143
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions compile_errors/non_void_error_union_payload_ignored.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pub export fn entry1() void {
var x: anyerror!usize = 5;
if (x) {
// foo
} else |_| {
// bar
}
}
pub export fn entry2() void {
var x: anyerror!usize = 5;
while (x) {
// foo
} else |_| {
// bar
}
}

// error
// backend=stage2
// target=native
//
// :3:5: error: error union payload is ignored
// :3:5: note: payload value can be explicitly ignored with '|_|'
// :11:5: error: error union payload is ignored
// :11:5: note: payload value can be explicitly ignored with '|_|'

0 comments on commit 8566143

Please sign in to comment.