parser: simplify parse_generic_struct_inst_type() (#9801)
parent
22351a6fb7
commit
3158617ce2
|
@ -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)
|
||||
} 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)
|
||||
return p.parse_enum_or_struct_type(name, .v).set_flag(.generic)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue