interp: fix derivation of type of slice expression of binary object
Fixes #1328.
This commit is contained in:
16
_test/issue-1328.go
Normal file
16
_test/issue-1328.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func main() {
|
||||
script := "hello"
|
||||
sumRaw := sha1.Sum([]byte(script))
|
||||
sum := hex.EncodeToString(sumRaw[:])
|
||||
println(sum)
|
||||
}
|
||||
|
||||
// Output:
|
||||
// aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
|
||||
@@ -854,6 +854,14 @@ func nodeType2(interp *Interpreter, sc *scope, n *node, seen []*node) (t *itype,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if t.cat == valueT {
|
||||
switch t.rtype.Kind() {
|
||||
case reflect.Array, reflect.Ptr:
|
||||
t = valueTOf(reflect.SliceOf(t.rtype.Elem()), withScope(sc))
|
||||
}
|
||||
break
|
||||
}
|
||||
if t.cat == ptrT {
|
||||
t = t.val
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user