From dc9eca83e872206db14af46f82735dc8678c6746 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Fri, 3 May 2024 05:30:58 +0200 Subject: [PATCH] operator-builtin.go: Fixed a problem with the list of forms due to changing []any in ListType --- operator-builtin.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/operator-builtin.go b/operator-builtin.go index 4d29488..093177d 100644 --- a/operator-builtin.go +++ b/operator-builtin.go @@ -17,16 +17,18 @@ func newBuiltinTerm(tk *Token) (inst *term) { } func evalBuiltin(ctx ExprContext, self *term) (v any, err error) { - var rightValue any + var childValue any + var it Iterator - if rightValue, err = self.evalPrefix(ctx); err != nil { + if childValue, err = self.evalPrefix(ctx); err != nil { return } count := 0 - if isList(rightValue) { - list, _ := rightValue.([]any) - for i, moduleSpec := range list { + if isList(childValue) { + list, _ := childValue.(*ListType) + it := NewFlatArrayIterator(*list) + for moduleSpec, err1 := it.Next(); err1 == nil; moduleSpec, err1 = it.Next() { if module, ok := moduleSpec.(string); ok { if ImportInContext(ctx, module) { count++ @@ -35,15 +37,15 @@ func evalBuiltin(ctx ExprContext, self *term) (v any, err error) { break } } else { - err = self.Errorf("expected string at item nr %d, got %T", i+1, moduleSpec) + err = self.Errorf("expected string at item nr %d, got %T", it.Index()+1, moduleSpec) break } } - } else if isString(rightValue) { - module, _ := rightValue.(string) + } else if isString(childValue) { + module, _ := childValue.(string) count, err = ImportInContextByGlobPattern(ctx, module) } else { - err = self.errIncompatibleType(rightValue) + err = self.errIncompatibleType(childValue) } if err == nil { v = count