mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: prevent a segfault, when compiling cmd/tools/vtest-vet.v in PR 6754
This commit is contained in:
parent
3f9b05a876
commit
953d102996
@ -390,9 +390,9 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
|
||||
typ := table.new_type(reg_idx)
|
||||
mut ts := p.table.get_type_symbol(typ)
|
||||
// if methods were declared before, it's an error, ignore them
|
||||
ts.methods.clear()
|
||||
ts.methods = []table.Fn{cap:20}
|
||||
// Parse methods
|
||||
mut methods := []ast.FnDecl{}
|
||||
mut methods := []ast.FnDecl{cap:20}
|
||||
for p.tok.kind != .rcbr && p.tok.kind != .eof {
|
||||
method_start_pos := p.tok.position()
|
||||
line_nr := p.tok.line_nr
|
||||
@ -425,7 +425,8 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
|
||||
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
|
||||
method.return_type = p.parse_type()
|
||||
}
|
||||
method.comments = p.eat_comments()
|
||||
mcomments := p.eat_comments()
|
||||
method.comments = mcomments
|
||||
methods << method
|
||||
// println('register method $name')
|
||||
return_type_sym := p.table.get_type_symbol(method.return_type)
|
||||
|
Loading…
Reference in New Issue
Block a user