@@ -523,16 +523,6 @@ fn (mut c Checker) struct_init(mut node ast.StructInit, is_field_zero_struct_ini
523523 c.error ('union `${struct_sym .name }` can have only one field initialised' ,
524524 node.pos)
525525 }
526- } else if struct_sym.info is ast.Alias {
527- parent_sym := c.table.sym (struct_sym.info.parent_type)
528- // e.g. ´x := MyMapAlias{}´, should be a cast to alias type ´x := MyMapAlias(map[...]...)´
529- if parent_sym.kind == .map {
530- alias_str := c.table.type_to_str (node.typ)
531- map_str := c.table.type_to_str (struct_sym.info.parent_type)
532- c.error ('direct map alias init is not possible, use `${alias_str }(${map_str }{})` instead' ,
533- node.pos)
534- return ast.void_type
535- }
536526 } else if struct_sym.info is ast.FnType {
537527 c.error ('functions must be defined, not instantiated like structs' , node.pos)
538528 }
@@ -649,8 +639,8 @@ fn (mut c Checker) struct_init(mut node ast.StructInit, is_field_zero_struct_ini
649639 .struct {
650640 info = sym.info as ast.Struct
651641 }
652- .array, .array_fixed {
653- // we do allow []int{}, [10]int{}
642+ .array, .array_fixed, . map {
643+ // we do allow []int{}, [10]int{}, map[string]int{}
654644 }
655645 else {
656646 c.error ('alias type name: ${sym .name } is not struct type' , node.pos)
0 commit comments