diff --git a/vlib/v/checker/or_block_assert_err.out b/vlib/v/checker/or_block_assert_err.out new file mode 100644 index 00000000000000..8c63da10f38862 --- /dev/null +++ b/vlib/v/checker/or_block_assert_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/or_block_assert_err.vv:7:23: error: last statement in the `or {}` block should be an expression of type `int` or exit parent scope + 5 | + 6 | fn main() { + 7 | a := f() or { assert true } + | ~~~~~~ + 8 | dump(a) + 9 | f() or { assert true } +vlib/v/checker/or_block_assert_err.vv:11:24: error: last statement in the `or {}` block should be an expression of type `int` or exit parent scope + 9 | f() or { assert true } + 10 | + 11 | b := ff() or { assert true } + | ~~~~~~ + 12 | dump(b) + 13 | ff() or { assert true } diff --git a/vlib/v/checker/or_block_assert_err.vv b/vlib/v/checker/or_block_assert_err.vv new file mode 100644 index 00000000000000..20c113693d34cf --- /dev/null +++ b/vlib/v/checker/or_block_assert_err.vv @@ -0,0 +1,17 @@ +fn f() !int { + return error('') +} + +fn ff() ?int { + return none +} + +fn main() { + a := f() or { assert true } + dump(a) + f() or { assert true } + + b := ff() or { assert true } + dump(b) + ff() or { assert true } +}