fmt: format explicit map init with parameter (#12499)
parent
ae54cd78f5
commit
b5e410e408
|
@ -14,3 +14,9 @@ numbers := {
|
||||||
'sevenhundredseventyseven': 777
|
'sevenhundredseventyseven': 777
|
||||||
'fivethousandthreehundredtwentyseven': 5327
|
'fivethousandthreehundredtwentyseven': 5327
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit_init := map[string]string{}
|
||||||
|
|
||||||
|
explicit_init_with_value := {
|
||||||
|
'abc': 0
|
||||||
|
}
|
||||||
|
|
|
@ -14,3 +14,9 @@ numbers := {
|
||||||
'sevenhundredseventyseven': 777
|
'sevenhundredseventyseven': 777
|
||||||
'fivethousandthreehundredtwentyseven': 5327
|
'fivethousandthreehundredtwentyseven': 5327
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit_init := map[string]string{}
|
||||||
|
|
||||||
|
explicit_init_with_value := map[string]int{
|
||||||
|
'abc': 0
|
||||||
|
}
|
||||||
|
|
|
@ -2034,6 +2034,11 @@ pub fn (mut p Parser) name_expr() ast.Expr {
|
||||||
if p.tok.kind == .rcbr {
|
if p.tok.kind == .rcbr {
|
||||||
p.next()
|
p.next()
|
||||||
} else {
|
} else {
|
||||||
|
if p.pref.is_fmt {
|
||||||
|
map_init := p.map_init()
|
||||||
|
p.check(.rcbr)
|
||||||
|
return map_init
|
||||||
|
}
|
||||||
p.error('`}` expected; explicit `map` initialization does not support parameters')
|
p.error('`}` expected; explicit `map` initialization does not support parameters')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue