File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -289,10 +289,21 @@ func DumpExpr(e ast.Expr, fset *token.FileSet) map[string]interface{} {
289
289
}
290
290
291
291
if n , ok := e .(* ast.CompositeLit ); ok {
292
+ // unlike most 'type' nodes, types in CompositeLits can be omitted,
293
+ // e.g. when you have a composite inside another one, which gives the
294
+ // inner composites an implicit type:
295
+ // bool[][] { { false, true }, { true, false }}
296
+
297
+ var declared map [string ]interface {} = nil
298
+
299
+ if n .Type != nil {
300
+ declared = DumpExprAsType (n .Type , fset )
301
+ }
302
+
292
303
return map [string ]interface {}{
293
304
"kind" : "literal" ,
294
305
"type" : "composite" ,
295
- "declared" : DumpExprAsType ( n . Type , fset ) ,
306
+ "declared" : declared ,
296
307
"values" : DumpExprs (n .Elts , fset ),
297
308
"position" : DumpPosition (fset .Position (e .Pos ())),
298
309
}
You can’t perform that action at this time.
0 commit comments