parser: fix error for fn with type only argument (fix #13704) (#13709)

pull/13711/head
yuyi 2022-03-11 04:52:06 +08:00 committed by GitHub
parent dd06698ee3
commit 3f351036a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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
}