| 1 | fn returns() usize { |
| 2 | return 2; |
| 3 | } |
| 4 | export fn f1() void { |
| 5 | while (true) returns(); |
| 6 | } |
| 7 | export fn f2() void { |
| 8 | var x: ?i32 = null; |
| 9 | _ = &x; |
| 10 | while (x) |_| returns(); |
| 11 | } |
| 12 | export fn f3() void { |
| 13 | var x: anyerror!i32 = error.Bad; |
| 14 | _ = &x; |
| 15 | while (x) |_| returns() else |_| unreachable; |
| 16 | } |
| 17 | export fn f4() void { |
| 18 | var a = true; |
| 19 | _ = &a; |
| 20 | while (a) {} else true; |
| 21 | } |
| 22 | export fn f5() void { |
| 23 | var a = true; |
| 24 | _ = &a; |
| 25 | const foo = while (a) returns() else true; |
| 26 | _ = foo; |
| 27 | } |
| 28 | |
| 29 | // error |
| 30 | // |
| 31 | // :5:25: error: value of type 'usize' ignored |
| 32 | // :5:25: note: all non-void values must be used |
| 33 | // :5:25: note: to discard the value, assign it to '_' |
| 34 | // :10:26: error: value of type 'usize' ignored |
| 35 | // :10:26: note: all non-void values must be used |
| 36 | // :10:26: note: to discard the value, assign it to '_' |
| 37 | // :15:26: error: value of type 'usize' ignored |
| 38 | // :15:26: note: all non-void values must be used |
| 39 | // :15:26: note: to discard the value, assign it to '_' |
| 40 | // :20:23: error: value of type 'bool' ignored |
| 41 | // :20:23: note: all non-void values must be used |
| 42 | // :20:23: note: to discard the value, assign it to '_' |
| 43 | // :25:34: error: value of type 'usize' ignored |
| 44 | // :25:34: note: all non-void values must be used |
| 45 | // :25:34: note: to discard the value, assign it to '_' |