mirror of
https://github.com/vlang/v.git
synced 2025-09-17 11:26:17 -04:00
This commit is contained in:
parent
1c2f1a3504
commit
7aca8b69da
@ -359,6 +359,10 @@ fn has_top_return(stmts []ast.Stmt) bool {
|
|||||||
if stmt.expr.method_name == 'compile_error' {
|
if stmt.expr.method_name == 'compile_error' {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
} else if stmt.expr is ast.LockExpr {
|
||||||
|
if has_top_return(stmt.expr.stmts) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {}
|
else {}
|
||||||
|
7
vlib/v/checker/tests/lockexpr_missing_return_err.out
Normal file
7
vlib/v/checker/tests/lockexpr_missing_return_err.out
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
vlib/v/checker/tests/lockexpr_missing_return_err.vv:4:1: error: missing return at end of function `baz`
|
||||||
|
2 | }
|
||||||
|
3 |
|
||||||
|
4 | fn baz(shared foo Foo) int {
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
5 | lock foo {
|
||||||
|
6 | }
|
18
vlib/v/checker/tests/lockexpr_missing_return_err.vv
Normal file
18
vlib/v/checker/tests/lockexpr_missing_return_err.vv
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
struct Foo {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn baz(shared foo Foo) int {
|
||||||
|
lock foo {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar(shared foo Foo) int {
|
||||||
|
lock foo {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
shared foo := Foo{}
|
||||||
|
bar(shared foo)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user