mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
0133ff2cbf
commit
b6ce7cc198
@ -2756,6 +2756,9 @@ pub fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
|
||||
} else {
|
||||
typ = obj.expr.expr_type.clear_flag(.optional).clear_flag(.result)
|
||||
}
|
||||
} else if obj.expr is ast.EmptyExpr {
|
||||
c.error('invalid variable `$node.name`', node.pos)
|
||||
typ = ast.void_type
|
||||
} else {
|
||||
typ = c.expr(obj.expr)
|
||||
}
|
||||
|
19
vlib/v/checker/tests/invalid_variable_err.out
Normal file
19
vlib/v/checker/tests/invalid_variable_err.out
Normal file
@ -0,0 +1,19 @@
|
||||
vlib/v/checker/tests/invalid_variable_err.vv:2:5: warning: unused variable: `b`
|
||||
1 | fn main() {
|
||||
2 | a, b := c
|
||||
| ^
|
||||
3 | if a {
|
||||
4 | }
|
||||
vlib/v/checker/tests/invalid_variable_err.vv:2:7: error: assignment mismatch: 2 variable(s) 1 value(s)
|
||||
1 | fn main() {
|
||||
2 | a, b := c
|
||||
| ~~
|
||||
3 | if a {
|
||||
4 | }
|
||||
vlib/v/checker/tests/invalid_variable_err.vv:3:5: error: invalid variable `a`
|
||||
1 | fn main() {
|
||||
2 | a, b := c
|
||||
3 | if a {
|
||||
| ^
|
||||
4 | }
|
||||
5 | }
|
5
vlib/v/checker/tests/invalid_variable_err.vv
Normal file
5
vlib/v/checker/tests/invalid_variable_err.vv
Normal file
@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
a, b := c
|
||||
if a {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user