mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: simplify parse_generic_struct_inst_type() (#9801)
This commit is contained in:
parent
22351a6fb7
commit
3158617ce2
28
vlib/v/fmt/tests/generic_recursive_structs_keep.vv
Normal file
28
vlib/v/fmt/tests/generic_recursive_structs_keep.vv
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
pub struct Node<T> {
|
||||||
|
value T
|
||||||
|
points_to []&Node<T>
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
mid := &Node<string>{
|
||||||
|
value: 'Middle'
|
||||||
|
}
|
||||||
|
finish := &Node<string>{
|
||||||
|
value: 'Finish'
|
||||||
|
}
|
||||||
|
|
||||||
|
graph := &Node<string>{
|
||||||
|
value: 'Start'
|
||||||
|
points_to: [
|
||||||
|
&Node<string>{
|
||||||
|
value: 'TopLeft'
|
||||||
|
points_to: [
|
||||||
|
finish,
|
||||||
|
mid,
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
println(graph.points_to[0].value) // 'TopLeft'
|
||||||
|
}
|
@ -523,11 +523,6 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) ast.Type {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
return ast.new_type(idx)
|
return ast.new_type(idx)
|
||||||
} else {
|
|
||||||
idx := p.table.find_type_idx(name)
|
|
||||||
if idx != 0 {
|
|
||||||
return ast.new_type(idx).set_flag(.generic)
|
|
||||||
}
|
}
|
||||||
}
|
return p.parse_enum_or_struct_type(name, .v).set_flag(.generic)
|
||||||
return p.parse_enum_or_struct_type(name, .v)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user