lang: core, funcs: Use the correct zero type
I wasn't using the correct contained type here.
This commit is contained in:
@@ -232,7 +232,7 @@ func (obj *ListLookupFunc) Copy() interfaces.Func {
|
||||
func (obj *ListLookupFunc) Function(ctx context.Context, input []types.Value) (types.Value, error) {
|
||||
l := (input[0]).(*types.ListValue)
|
||||
index := input[1].Int()
|
||||
//zero := l.Type().New() // the zero value
|
||||
//zero := l.Type().Val.New() // the zero value
|
||||
|
||||
// TODO: should we handle overflow by returning zero?
|
||||
if index > math.MaxInt { // max int size varies by arch
|
||||
|
||||
@@ -234,7 +234,7 @@ func (obj *MapLookupFunc) Copy() interfaces.Func {
|
||||
func (obj *MapLookupFunc) Function(ctx context.Context, input []types.Value) (types.Value, error) {
|
||||
m := (input[0]).(*types.MapValue)
|
||||
key := input[1]
|
||||
//zero := m.Type().New() // the zero value
|
||||
//zero := m.Type().Val.New() // the zero value
|
||||
|
||||
val, exists := m.Lookup(key)
|
||||
if exists {
|
||||
|
||||
@@ -186,7 +186,7 @@ func (obj *ListLookupFunc) Stream(ctx context.Context) error {
|
||||
|
||||
l := (input.Struct()[listLookupArgNameList]).(*types.ListValue)
|
||||
index := input.Struct()[listLookupArgNameIndex].Int()
|
||||
zero := l.Type().New() // the zero value
|
||||
zero := l.Type().Val.New() // the zero value
|
||||
|
||||
// TODO: should we handle overflow by returning zero?
|
||||
if index > math.MaxInt { // max int size varies by arch
|
||||
|
||||
@@ -189,7 +189,7 @@ func (obj *MapLookupFunc) Stream(ctx context.Context) error {
|
||||
|
||||
m := (input.Struct()[mapLookupArgNameMap]).(*types.MapValue)
|
||||
key := input.Struct()[mapLookupArgNameKey]
|
||||
zero := m.Type().New() // the zero value
|
||||
zero := m.Type().Val.New() // the zero value
|
||||
|
||||
var result types.Value
|
||||
val, exists := m.Lookup(key)
|
||||
|
||||
Reference in New Issue
Block a user