From c7f965526204a46d4f7d2a22557abfca80a0756a Mon Sep 17 00:00:00 2001 From: MattMc <4984708+tooolbox@users.noreply.github.com> Date: Sat, 5 Sep 2020 15:34:19 -0700 Subject: [PATCH] Fix ranger selection when indirecting to a map. --- eval.go | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/eval.go b/eval.go index b4fe5ad..b26e739 100644 --- a/eval.go +++ b/eval.go @@ -1556,25 +1556,28 @@ func getRanger(v reflect.Value) Ranger { return v.Interface().(Ranger) } k := tuP.Kind() - switch k { - case reflect.Ptr, reflect.Interface: - v = v.Elem() - k = v.Kind() - fallthrough - case reflect.Slice, reflect.Array: - sliceranger := pool_sliceRanger.Get().(*sliceRanger) - sliceranger.i = -1 - sliceranger.len = v.Len() - sliceranger.v = v - return sliceranger - case reflect.Map: - mapranger := pool_mapRanger.Get().(*mapRanger) - *mapranger = mapRanger{v: v, keys: v.MapKeys(), len: v.Len()} - return mapranger - case reflect.Chan: - chanranger := pool_chanRanger.Get().(*chanRanger) - *chanranger = chanRanger{v: v} - return chanranger + for { + switch k { + case reflect.Ptr, reflect.Interface: + v = v.Elem() + k = v.Kind() + continue + case reflect.Slice, reflect.Array: + sliceranger := pool_sliceRanger.Get().(*sliceRanger) + sliceranger.i = -1 + sliceranger.len = v.Len() + sliceranger.v = v + return sliceranger + case reflect.Map: + mapranger := pool_mapRanger.Get().(*mapRanger) + *mapranger = mapRanger{v: v, keys: v.MapKeys(), len: v.Len()} + return mapranger + case reflect.Chan: + chanranger := pool_chanRanger.Get().(*chanRanger) + *chanranger = chanRanger{v: v} + return chanranger + } + break } panic(fmt.Errorf("type %s is not rangeable", tuP)) }