From 6bd35505a2031a98aa3fe57fcb6e8c130ae61fcd Mon Sep 17 00:00:00 2001 From: zakuro Date: Sat, 2 Jan 2021 22:09:54 +0900 Subject: [PATCH] parser: fix error when using imported types in short fn signature (#7795) --- vlib/v/parser/fn.v | 3 ++- vlib/v/tests/fn_test.v | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 832f89494a..453abcb702 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -493,7 +493,8 @@ fn (mut p Parser) fn_args() ([]table.Param, bool, bool) { p.tok.lit } types_only := p.tok.kind in [.amp, .ellipsis, .key_fn] || - (p.peek_tok.kind == .comma && p.table.known_type(argname)) || p.peek_tok.kind == .rpar + (p.peek_tok.kind == .comma && p.table.known_type(argname)) || p.peek_tok.kind == .dot || + p.peek_tok.kind == .rpar // TODO copy pasta, merge 2 branches if types_only { // p.warn('types only') diff --git a/vlib/v/tests/fn_test.v b/vlib/v/tests/fn_test.v index bc43dfe2b1..2b99572b29 100644 --- a/vlib/v/tests/fn_test.v +++ b/vlib/v/tests/fn_test.v @@ -1,3 +1,4 @@ +import time // 1 line comment // 1 line comment /* multi line comment (1) @@ -40,6 +41,8 @@ type F5 = fn (int, int) int type F6 = fn (int, int) +type F7 = fn (time.Time, int) + fn C.atoi(byteptr) int fn foo() {