parser: fix parsing attribute after fn prototype with no return type (#8727)
parent
e4f15605c0
commit
82650ee813
|
@ -327,8 +327,10 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
|||
mut end_pos := p.prev_tok.position()
|
||||
// Return type
|
||||
mut return_type := table.void_type
|
||||
if p.tok.kind.is_start_of_type()
|
||||
|| (p.tok.kind == .key_fn && p.tok.line_nr == p.prev_tok.line_nr) {
|
||||
// don't confuse token on the next line: fn decl, [attribute]
|
||||
same_line := p.tok.line_nr == p.prev_tok.line_nr
|
||||
if (p.tok.kind.is_start_of_type() && (same_line || p.tok.kind != .lsbr))
|
||||
|| (same_line && p.tok.kind == .key_fn) {
|
||||
return_type = p.parse_type()
|
||||
}
|
||||
mut type_sym_method_idx := 0
|
||||
|
|
|
@ -44,6 +44,11 @@ type F6 = fn (int, int)
|
|||
type F7 = fn (time.Time, int)
|
||||
|
||||
fn C.atoi(byteptr) int
|
||||
fn C.freec(ptr voidptr)
|
||||
|
||||
[trusted]
|
||||
fn C.exitc(code int)
|
||||
// above checks attribute doesn't conflict with `freec` return type
|
||||
|
||||
fn foo() {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue