diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 0e8d2854a2..42c6a99c0c 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -736,7 +736,8 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) { || (p.peek_tok.kind == .comma && p.table.known_type(argname)) || p.peek_tok.kind == .dot || p.peek_tok.kind == .rpar || (p.tok.kind == .key_mut && (p.peek_token(2).kind == .comma - || p.peek_token(2).kind == .rpar)) + || p.peek_token(2).kind == .rpar || (p.peek_token(1).kind == .name + && p.peek_token(2).kind == .dot))) // TODO copy pasta, merge 2 branches if types_only { mut arg_no := 1 diff --git a/vlib/v/tests/fn_type_only_argument_test.v b/vlib/v/tests/fn_type_only_argument_test.v new file mode 100644 index 0000000000..57b69559fb --- /dev/null +++ b/vlib/v/tests/fn_type_only_argument_test.v @@ -0,0 +1,16 @@ +module main + +import time + +struct Game { + update fn (mut time.Time) = fn (mut time time.Time) {} + draw fn (mut time.Time) = fn (mut time time.Time) {} +mut: + time time.Time +} + +fn test_fn_type_only_argument() { + mut game := Game{} + game.time = time.Time{} + assert true +}