mirror of
https://github.com/vlang/v.git
synced 2025-09-15 23:42:28 +03:00
allow short struct initialization with Config structs
This commit is contained in:
parent
0b235cc893
commit
6b3f54692a
3 changed files with 11 additions and 1 deletions
|
@ -902,6 +902,13 @@ fn (p mut Parser) factor() string {
|
|||
if p.peek() == .str {
|
||||
return p.map_init()
|
||||
}
|
||||
peek2 := p.tokens[p.token_idx + 1]
|
||||
if p.peek() == .name && peek2.tok == .colon {
|
||||
if !p.expected_type.ends_with('Config') {
|
||||
p.error('short struct initialization syntax only works with structs that end with `Config`')
|
||||
}
|
||||
return p.struct_init(p.expected_type)
|
||||
}
|
||||
// { user | name :'new name' }
|
||||
return p.assoc()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue