Skip to content

Commit 3158617

Browse files
authored
parser: simplify parse_generic_struct_inst_type() (#9801)
1 parent 22351a6 commit 3158617

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pub struct Node<T> {
2+
value T
3+
points_to []&Node<T>
4+
}
5+
6+
fn main() {
7+
mid := &Node<string>{
8+
value: 'Middle'
9+
}
10+
finish := &Node<string>{
11+
value: 'Finish'
12+
}
13+
14+
graph := &Node<string>{
15+
value: 'Start'
16+
points_to: [
17+
&Node<string>{
18+
value: 'TopLeft'
19+
points_to: [
20+
finish,
21+
mid,
22+
]
23+
},
24+
]
25+
}
26+
27+
println(graph.points_to[0].value) // 'TopLeft'
28+
}

vlib/v/parser/parse_type.v

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,6 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) ast.Type {
523523
}
524524
})
525525
return ast.new_type(idx)
526-
} else {
527-
idx := p.table.find_type_idx(name)
528-
if idx != 0 {
529-
return ast.new_type(idx).set_flag(.generic)
530-
}
531526
}
532-
return p.parse_enum_or_struct_type(name, .v)
527+
return p.parse_enum_or_struct_type(name, .v).set_flag(.generic)
533528
}

0 commit comments

Comments
 (0)