mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix required function members in struct (#10299)
This commit is contained in:
@@ -212,7 +212,7 @@ pub fn (mut p Parser) parse_fn_type(name string) ast.Type {
|
||||
}
|
||||
mut return_type := ast.void_type
|
||||
mut return_type_pos := token.Position{}
|
||||
if p.tok.line_nr == line_nr && p.tok.kind.is_start_of_type() {
|
||||
if p.tok.line_nr == line_nr && p.tok.kind.is_start_of_type() && !p.is_attributes() {
|
||||
return_type_pos = p.tok.position()
|
||||
return_type = p.parse_type()
|
||||
if return_type.has_flag(.generic) {
|
||||
|
||||
@@ -1460,6 +1460,28 @@ fn (mut p Parser) expr_list() ([]ast.Expr, []ast.Comment) {
|
||||
return exprs, comments
|
||||
}
|
||||
|
||||
fn (mut p Parser) is_attributes() bool {
|
||||
if p.tok.kind != .lsbr {
|
||||
return false
|
||||
}
|
||||
mut i := 0
|
||||
for {
|
||||
tok := p.peek_token(i)
|
||||
if tok.kind == .eof || tok.line_nr != p.tok.line_nr {
|
||||
return false
|
||||
}
|
||||
if tok.kind == .rsbr {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
peek_rsbr_tok := p.peek_token(i + 1)
|
||||
if peek_rsbr_tok.line_nr == p.tok.line_nr && peek_rsbr_tok.kind != .rcbr {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// when is_top_stmt is true attrs are added to p.attrs
|
||||
fn (mut p Parser) attributes() {
|
||||
p.check(.lsbr)
|
||||
|
||||
Reference in New Issue
Block a user