diff --git a/vlib/v/checker/tests/call_empty_or_block_err.out b/vlib/v/checker/tests/call_empty_or_block_err.out new file mode 100644 index 00000000000000..6021adfdf57dc3 --- /dev/null +++ b/vlib/v/checker/tests/call_empty_or_block_err.out @@ -0,0 +1,35 @@ +vlib/v/checker/tests/call_empty_or_block_err.vv:10:2: warning: unused variable: `a` + 8 | + 9 | fn test_main() { + 10 | a := foo() or { + | ^ + 11 | foo() or {} + 12 | } +vlib/v/checker/tests/call_empty_or_block_err.vv:14:2: warning: unused variable: `y` + 12 | } + 13 | + 14 | y := if c := foo() { + | ^ + 15 | dump(c) + 16 | bar() or {} +vlib/v/checker/tests/call_empty_or_block_err.vv:21:2: warning: unused variable: `z` + 19 | } + 20 | + 21 | z := if d := foo() { + | ^ + 22 | dump(d) + 23 | bar() or {} +vlib/v/checker/tests/call_empty_or_block_err.vv:11:9: error: assignment requires a non empty `or {}` block + 9 | fn test_main() { + 10 | a := foo() or { + 11 | foo() or {} + | ~~~~~ + 12 | } + 13 | +vlib/v/checker/tests/call_empty_or_block_err.vv:16:3: error: the final expression in `if` or `match`, must have a value of a non-void type + 14 | y := if c := foo() { + 15 | dump(c) + 16 | bar() or {} + | ~~~~~ + 17 | } else { + 18 | false diff --git a/vlib/v/checker/tests/call_empty_or_block_err.vv b/vlib/v/checker/tests/call_empty_or_block_err.vv new file mode 100644 index 00000000000000..3da496b88168f4 --- /dev/null +++ b/vlib/v/checker/tests/call_empty_or_block_err.vv @@ -0,0 +1,25 @@ +fn foo() !bool { + return true +} + +fn bar() ! { +} + +fn test_main() { + a := foo() or { foo() or {} } + + y := if c := foo() { + dump(c) + bar() or {} + } else { + false + } + + z := if d := foo() { + dump(d) + bar() or {} + true + } else { + false + } +}