mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
e9a3817aed
commit
fcef8c98ee
@ -195,7 +195,8 @@ fn (mut g Gen) array_init_with_fields(node ast.ArrayInit, elem_type Type, is_amp
|
|||||||
noscan := g.check_noscan(elem_type.typ)
|
noscan := g.check_noscan(elem_type.typ)
|
||||||
is_default_array := elem_type.unaliased_sym.kind == .array && node.has_default
|
is_default_array := elem_type.unaliased_sym.kind == .array && node.has_default
|
||||||
is_default_map := elem_type.unaliased_sym.kind == .map && node.has_default
|
is_default_map := elem_type.unaliased_sym.kind == .map && node.has_default
|
||||||
needs_more_defaults := node.has_len && g.struct_has_array_or_map_field(elem_type.typ)
|
needs_more_defaults := node.has_len && (g.struct_has_array_or_map_field(elem_type.typ)
|
||||||
|
|| elem_type.unaliased_sym.kind in [.array, .map])
|
||||||
if node.has_it { // []int{len: 6, init: it * it} when variable it is used in init expression
|
if node.has_it { // []int{len: 6, init: it * it} when variable it is used in init expression
|
||||||
g.inside_lambda = true
|
g.inside_lambda = true
|
||||||
mut tmp := g.new_tmp_var()
|
mut tmp := g.new_tmp_var()
|
||||||
|
@ -257,3 +257,18 @@ fn test_multi_array_update_data() {
|
|||||||
println(a)
|
println(a)
|
||||||
assert '${a}' == '[[[0, 0], [0, 2], [0, 0]], [[0, 0], [0, 0], [0, 0]]]'
|
assert '${a}' == '[[[0, 0], [0, 2], [0, 0]], [[0, 0], [0, 0], [0, 0]]]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_array_of_map_with_len_no_default() {
|
||||||
|
mut arr := []map[int]int{len: 3}
|
||||||
|
arr[0][0] = 0
|
||||||
|
arr[1][1] = 1
|
||||||
|
arr[2][2] = 2
|
||||||
|
println(arr)
|
||||||
|
assert arr == [{
|
||||||
|
0: 0
|
||||||
|
}, {
|
||||||
|
1: 1
|
||||||
|
}, {
|
||||||
|
2: 2
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user