operator-builtin.go: Fixed a problem with the list of forms due to changing []any in ListType

This commit is contained in:
Celestino Amoroso 2024-05-03 05:30:58 +02:00
parent 2c55167dd0
commit dc9eca83e8

View File

@ -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