Skip to content

Commit 3f35103

Browse files
authored
parser: fix error for fn with type only argument (fix #13704) (#13709)
1 parent dd06698 commit 3f35103

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

vlib/v/parser/fn.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
736736
|| (p.peek_tok.kind == .comma && p.table.known_type(argname))
737737
|| p.peek_tok.kind == .dot || p.peek_tok.kind == .rpar
738738
|| (p.tok.kind == .key_mut && (p.peek_token(2).kind == .comma
739-
|| p.peek_token(2).kind == .rpar))
739+
|| p.peek_token(2).kind == .rpar || (p.peek_token(1).kind == .name
740+
&& p.peek_token(2).kind == .dot)))
740741
// TODO copy pasta, merge 2 branches
741742
if types_only {
742743
mut arg_no := 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module main
2+
3+
import time
4+
5+
struct Game {
6+
update fn (mut time.Time) = fn (mut time time.Time) {}
7+
draw fn (mut time.Time) = fn (mut time time.Time) {}
8+
mut:
9+
time time.Time
10+
}
11+
12+
fn test_fn_type_only_argument() {
13+
mut game := Game{}
14+
game.time = time.Time{}
15+
assert true
16+
}

0 commit comments

Comments
 (0)