fix: composite literal child types for call expressions
This commit is contained in:
14
_test/composite10.go
Normal file
14
_test/composite10.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
a := []map[int]int{make(map[int]int)}
|
||||
|
||||
for _, b := range a {
|
||||
fmt.Println(b)
|
||||
}
|
||||
}
|
||||
|
||||
// Output:
|
||||
// map[]
|
||||
14
_test/composite9.go
Normal file
14
_test/composite9.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
a := [][]int{make([]int,0)}
|
||||
|
||||
for _, b := range a {
|
||||
fmt.Println(b)
|
||||
}
|
||||
}
|
||||
|
||||
// Output:
|
||||
// []
|
||||
@@ -248,6 +248,10 @@ func (interp *Interpreter) cfg(root *node, pkgID string) ([]*node, error) {
|
||||
case binaryExpr, unaryExpr:
|
||||
// Do not attempt to propagate composite type to operator expressions,
|
||||
// it breaks constant folding.
|
||||
case callExpr:
|
||||
if c.typ, err = nodeType(interp, sc, c); err != nil {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
c.typ = n.typ
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user