interp: added sliceExpr and starExpr

Type check was failing for expression such as: `&(*tree)[node:][0]`, as in

```go
tree, _ := huffmanTreePool.Get().(*[]huffmanTree)
...

initHuffmanTree(&(*tree)[node:][0], histogram[l], -1, int16(l))
```

see c3da72aa01/brotli_bit_stream.go (L469)
This commit is contained in:
rsteube
2020-10-21 18:14:03 +02:00
committed by GitHub
parent 22c63b225c
commit d7ede8ed5c
2 changed files with 26 additions and 1 deletions

22
_test/addr1.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import "fmt"
type T struct {
A int
B int
}
func main() {
a := &[]T{
{1, 2},
{3, 4},
}
fmt.Println("a:", a)
x := &(*a)[1:][0]
fmt.Println("x:", x)
}
// Output:
// a: &[{1 2} {3 4}]
// x: &{3 4}

View File

@@ -91,7 +91,10 @@ func (check typecheck) addressExpr(n *node) error {
case selectorExpr:
c0 = c0.child[1]
continue
case indexExpr:
case starExpr:
c0 = c0.child[0]
continue
case indexExpr, sliceExpr:
c := c0.child[0]
if isArray(c.typ) || isMap(c.typ) {
c0 = c