Skip to content

Commit

Permalink
new test
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 12, 2024
1 parent 84b5784 commit 9888f10
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
35 changes: 35 additions & 0 deletions vlib/v/checker/tests/call_empty_or_block_err.out
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions vlib/v/checker/tests/call_empty_or_block_err.vv
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 9888f10

Please sign in to comment.