diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 6cf6d0a7b76e1c..3464c518675470 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 == .name && p.peek_tok.kind == .colon { + if p.tok.kind in [.name, .key_type] && 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/keyword_as_params_field_test.v b/vlib/v/tests/keyword_as_params_field_test.v new file mode 100644 index 00000000000000..29394b6476bada --- /dev/null +++ b/vlib/v/tests/keyword_as_params_field_test.v @@ -0,0 +1,24 @@ +@[params] +struct FooParams { + type FooType = .first +} + +enum FooType { + first + second +} + +fn foo(params FooParams) string { + match params.type { + .first { + return 'First' + } + .second { + return 'Second' + } + } +} + +fn test_main() { + assert foo(type: .second) == 'Second' +}