node: add more diagnostics for mixed array/map literals

This commit is contained in:
mappu 2020-04-11 12:45:05 +12:00
parent d3d3d34116
commit 48f3014429

View File

@ -1658,8 +1658,9 @@ func (this *conversionState) convertArrayLiteralCommon(items []node.Node) (strin
if idx == 0 { if idx == 0 {
isMapType = (itm.Key != nil) isMapType = (itm.Key != nil)
} else { } else {
if isMapType != (itm.Key != nil) { thisElemIsMapType := (itm.Key != nil)
return "", parseErr{itm, fmt.Errorf("Can't represent array and map in a single type")} if isMapType != thisElemIsMapType {
return "", parseErr{itm, fmt.Errorf("Can't represent array and map in a single type (idx[0].isMap=%v != idx[%d].isMap=%v)", isMapType, idx, thisElemIsMapType)}
} }
} }