compiler: allow to omit types for nested slices

This commit is contained in:
Evgenii Stratonikov 2020-06-24 19:25:08 +03:00
parent 53f2e130c0
commit 5a615d8178
2 changed files with 26 additions and 9 deletions

View file

@ -594,15 +594,11 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
return nil
case *ast.CompositeLit:
typ := c.typeOf(n.Type).Underlying()
switch n.Type.(type) {
case *ast.Ident, *ast.SelectorExpr, *ast.MapType:
switch typ.(type) {
case *types.Struct:
c.convertStruct(n)
case *types.Map:
c.convertMap(n)
}
switch typ := c.typeOf(n).Underlying().(type) {
case *types.Struct:
c.convertStruct(n)
case *types.Map:
c.convertMap(n)
default:
ln := len(n.Elts)
// ByteArrays needs a different approach than normal arrays.