mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix infinite loop for type Handler = fn (test string) string
without newline at the end
This commit is contained in:
parent
f6844e9766
commit
710c2b22da
@ -471,6 +471,9 @@ fn (p &Parser) peek_token_after_var_list() token.Token {
|
||||
mut n := 0
|
||||
mut tok := p.tok
|
||||
for {
|
||||
if tok.kind == .eof {
|
||||
break
|
||||
}
|
||||
if tok.kind == .key_mut {
|
||||
n += 2
|
||||
} else {
|
||||
@ -495,6 +498,9 @@ fn (p &Parser) is_fn_type_decl() bool {
|
||||
cur_ln := p.tok.line_nr
|
||||
for {
|
||||
tok = p.scanner.peek_token(n)
|
||||
if tok.kind == .eof {
|
||||
break
|
||||
}
|
||||
if tok.kind in [.lpar, .rpar] {
|
||||
n++
|
||||
prev_tok = tok
|
||||
|
0
vlib/v/parser/tests/type_fn_eof_on_same_line.out
Normal file
0
vlib/v/parser/tests/type_fn_eof_on_same_line.out
Normal file
1
vlib/v/parser/tests/type_fn_eof_on_same_line.vv
Normal file
1
vlib/v/parser/tests/type_fn_eof_on_same_line.vv
Normal file
@ -0,0 +1 @@
|
||||
type Handler = fn (test string) string
|
Loading…
Reference in New Issue
Block a user