mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check untyped nil in assignment
This commit is contained in:
parent
1aeca113d3
commit
fd47385ff2
@ -220,6 +220,9 @@ pub fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
|||||||
c.error('invalid use of reserved type `$left.name` as a variable name',
|
c.error('invalid use of reserved type `$left.name` as a variable name',
|
||||||
left.pos)
|
left.pos)
|
||||||
}
|
}
|
||||||
|
if right is ast.Nil {
|
||||||
|
c.error('use of untyped nil in assignment', right.pos())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mut ident_var_info := left.info as ast.IdentVar
|
mut ident_var_info := left.info as ast.IdentVar
|
||||||
if ident_var_info.share == .shared_t {
|
if ident_var_info.share == .shared_t {
|
||||||
|
7
vlib/v/checker/tests/nil.out
Normal file
7
vlib/v/checker/tests/nil.out
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
vlib/v/checker/tests/nil.vv:3:18: error: use of untyped nil in assignment
|
||||||
|
1 | fn main() {
|
||||||
|
2 | unsafe {
|
||||||
|
3 | value := nil
|
||||||
|
| ~~~
|
||||||
|
4 | println(value)
|
||||||
|
5 | }
|
6
vlib/v/checker/tests/nil.vv
Normal file
6
vlib/v/checker/tests/nil.vv
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
fn main() {
|
||||||
|
unsafe {
|
||||||
|
value := nil
|
||||||
|
println(value)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user