1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: use single quotes around fixed string arr default expr (#7581)

This commit is contained in:
Lukas Neubert 2020-12-26 14:12:25 +01:00 committed by GitHub
parent e26e0c3f72
commit 9a5bbc3101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -1840,7 +1840,9 @@ pub fn (mut f Fmt) array_init(it ast.ArrayInit) {
}
f.write(f.table.type_to_str(it.elem_type))
if it.has_default {
f.write('{init: $it.default_expr}')
f.write('{init: ')
f.expr(it.default_expr)
f.write('}')
} else {
f.write('{}')
}

View File

@ -16,6 +16,10 @@ fn main() {
'eggs',
]
_ := []int{len: 10, cap: 10, init: 7}
_ := []map[string]string{len: 5, cap: 50, init: 'a'}
_ := []map[string][]int{len: 7, cap: 100, init: [1, 2]}
_ := []map[string]string{len: 5, cap: 50, init: {
'a': 'a'
}}
_ := []map[string][]int{len: 7, cap: 100, init: {
'a': [1, 2]
}}
}

View File

@ -1,3 +1,7 @@
fn foo() [1]f32 {
return [f32(0.0)]!!
}
fn main() {
_ := [5]string{init: 'abc'}
}