feat: add index and composite literal type checking

This adds type checking to both `IndexExpr` and `CompositeLitExpr` as well as handling any required constant type conversion.

This includes a change to the type propagation to the children of a composite literal. Previously in most cases the composite literal type was propagated to its children. This does not work with type checking as the actual child type is needed.
This commit is contained in:
Nicholas Wiersma
2020-08-11 15:58:04 +02:00
committed by GitHub
parent 88569f5df7
commit cdc352cee2
6 changed files with 361 additions and 45 deletions

View File

@@ -1315,7 +1315,6 @@ func getIndexMap(n *node) {
z := reflect.New(n.child[0].typ.frameType().Elem()).Elem()
if n.child[1].rval.IsValid() { // constant map index
convertConstantValue(n.child[1])
mi := n.child[1].rval
switch {
@@ -1409,7 +1408,6 @@ func getIndexMap2(n *node) {
return
}
if n.child[1].rval.IsValid() { // constant map index
convertConstantValue(n.child[1])
mi := n.child[1].rval
switch {
case !doValue: