v2 / vlib / v / tests / structs / struct_init_with_chan_field_test.v
19 lines · 15 sloc · 299 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct Abc {
2 def Def
3}
4
5struct Def {
6 ch chan string
7}
8
9fn test_struct_init_with_chan_field() {
10 abc1 := Abc{Def{}}
11 println('printing abc1')
12 println(abc1) // this works
13
14 abc2 := Abc{}
15 println('printing abc2')
16 println(abc2) // this gives invalid memory access
17
18 assert '${abc1}' == '${abc2}'
19}
20