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:
22
_test/addr1.go
Normal file
22
_test/addr1.go
Normal 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}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user