From 9a5f6a5bd39d8cb6fd617c7af69dc9b2388bb042 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 19 Aug 2024 00:46:23 -0400 Subject: [PATCH] lang: core, funcs: Use the correct zero type I wasn't using the correct contained type here. --- lang/core/list/list_lookup_func.go | 2 +- lang/core/map/map_lookup_func.go | 2 +- lang/funcs/list_lookup_func.go | 2 +- lang/funcs/map_lookup_func.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/core/list/list_lookup_func.go b/lang/core/list/list_lookup_func.go index 326fbc00e..73f6e8a73 100644 --- a/lang/core/list/list_lookup_func.go +++ b/lang/core/list/list_lookup_func.go @@ -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 diff --git a/lang/core/map/map_lookup_func.go b/lang/core/map/map_lookup_func.go index d6097825d..0c732cf66 100644 --- a/lang/core/map/map_lookup_func.go +++ b/lang/core/map/map_lookup_func.go @@ -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 { diff --git a/lang/funcs/list_lookup_func.go b/lang/funcs/list_lookup_func.go index 18a0c8ea2..6b91d61bb 100644 --- a/lang/funcs/list_lookup_func.go +++ b/lang/funcs/list_lookup_func.go @@ -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 diff --git a/lang/funcs/map_lookup_func.go b/lang/funcs/map_lookup_func.go index 3f5fd8512..d2ddf653d 100644 --- a/lang/funcs/map_lookup_func.go +++ b/lang/funcs/map_lookup_func.go @@ -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)