tests: add reference_field_must_be_initialized.vv

pull/4645/head
Delyan Angelov 2020-04-29 12:56:12 +03:00
parent bf8ed1815c
commit 1e910c6afe
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,7 @@
vlib/v/checker/tests/reference_field_must_be_initialized.v:8:7: error: reference field `Node.next` must be initialized
6|
7| fn main(){
8| n := Node{ data: 123 }
~~~~~~~~~~~~~~~~~
9| eprintln('n.data: $n.data')
10| }

View File

@ -0,0 +1,10 @@
module main
struct Node {
data int
next &Node = 0
}
fn main(){
n := Node{ data: 123 }
eprintln('n.data: $n.data')
}