parser: allow keyword as struct param key on fn call (fix #24957) (#24958)

This commit is contained in:
Felipe Pena 2025-07-23 14:48:03 -03:00 committed by GitHub
parent 4037765828
commit 7472a745e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

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

View File

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