diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 19237289d8..3ce9356817 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -141,7 +141,7 @@ fn (mut p Parser) call_args() []ast.CallArg { array_decompose = true } mut expr := ast.empty_expr - if p.tok.kind in [.name, .key_type] && p.peek_tok.kind == .colon { + if p.peek_tok.kind == .colon { // `foo(key:val, key2:val2)` expr = p.struct_init('void_type', .short_syntax, false) } else { diff --git a/vlib/v/tests/fns/call_struct_params_with_keyword_test.v b/vlib/v/tests/fns/call_struct_params_with_keyword_test.v new file mode 100644 index 0000000000..8236a6b12b --- /dev/null +++ b/vlib/v/tests/fns/call_struct_params_with_keyword_test.v @@ -0,0 +1,13 @@ +@[params] +struct Config { + dump bool +} + +fn test_main() { + opt := Config{} + run('x', dump: opt.dump)! +} + +fn run(source string, config Config) ! { + dump(config) +}