Open
Description
The following program sample.go
triggers an unexpected result
package main
import (
"go/types"
)
type B struct {
}
// Alignof returns the alignment of a variable of type T.
// Alignof must implement the alignment guarantees required by the spec.
func (b *B) Alignof(T types.Type) int64 {
return 0
}
// Offsetsof returns the offsets of the given struct fields, in bytes.
// Offsetsof must implement the offset guarantees required by the spec.
func (b *B) Offsetsof(fields []*types.Var) []int64 {
return nil
}
// Sizeof returns the size of a variable of type T.
// Sizeof must implement the size guarantees required by the spec.
func (b *B) Sizeof(T types.Type) int64 {
return 1
}
var (
originTables = map[types.Sizes]string{}
)
func Register(table types.Sizes, str string) {
originTables[table] = str
}
func main() {
Register(&B{}, "ss")
}
Expected result
no panic.
Got
sample.go:34:2: panic
sample.go:38:12: panic
run: runtime error: hash of unhashable type stdlib._go_types_Sizes
Yaegi Version
0.15.0
Additional Notes
// _go_types_Object is an interface wrapper for Object type
type _go_types_Object struct {
IValue interface{}
WExported func() bool
WId func() string
WName func() string
WParent func() *types.Scope
WPkg func() *types.Package
WPos func() token.Pos
WString func() string
WType func() types.Type
}
The key of a map cannot contain the func
field.