@@ -8,14 +8,14 @@ import v.token
88fn (mut c Checker) array_init (mut node ast.ArrayInit) ast.Type {
99 mut elem_type := ast.void_type
1010 unwrap_elem_type := c.unwrap_generic (node.elem_type)
11+ if node.typ.has_flag (.generic) {
12+ c.table.used_features.comptime_syms[c.unwrap_generic (node.typ)] = true
13+ }
1114 if c.pref.warn_about_allocs {
1215 c.warn_alloc ('array initialization' , node.pos)
1316 }
1417 // `x := []string{}` (the type was set in the parser)
1518 if node.typ != ast.void_type {
16- if ! c.is_builtin_mod && c.mod ! in ['builtin' , 'strings' , 'strconv' , 'math.bits' ] {
17- c.table.used_features.arr_init = true
18- }
1919 if node.elem_type != 0 {
2020 elem_sym := c.table.sym (node.elem_type)
2121 c.check_any_type (node.elem_type, elem_sym, node.pos)
@@ -159,9 +159,6 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type {
159159 }
160160 // `[1,2,3]`
161161 if node.exprs.len > 0 && node.elem_type == ast.void_type {
162- if ! c.is_builtin_mod && c.mod ! in ['builtin' , 'strings' , 'strconv' , 'math.bits' ] {
163- c.table.used_features.arr_init = true
164- }
165162 mut expected_value_type := ast.void_type
166163 mut expecting_interface_array := false
167164 mut expecting_sumtype_array := false
@@ -502,6 +499,9 @@ fn (mut c Checker) map_init(mut node ast.MapInit) ast.Type {
502499 // `x := map[string]string` - set in parser
503500 if node.typ != 0 {
504501 info := c.table.sym (node.typ).map_info ()
502+ if node.typ.has_flag (.generic) {
503+ c.table.used_features.comptime_syms[c.unwrap_generic (node.typ)] = true
504+ }
505505 if info.value_type != 0 {
506506 if info.value_type.has_flag (.result) {
507507 c.error ('cannot use Result type as map value type' , node.pos)
@@ -541,7 +541,6 @@ fn (mut c Checker) map_init(mut node ast.MapInit) ast.Type {
541541 }
542542
543543 if (node.keys.len > 0 && node.vals.len > 0 ) || node.has_update_expr {
544- c.table.used_features.map_update = true
545544 mut map_type := ast.void_type
546545 use_expected_type := c.expected_type != ast.void_type && ! c.inside_const
547546 && c.table.sym (c.expected_type).kind == .map && ! (c.inside_fn_arg
0 commit comments