operator-builtin.go: Fixed a problem with the list of forms due to changing []any in ListType
This commit is contained in:
parent
2c55167dd0
commit
dc9eca83e8
@ -17,16 +17,18 @@ func newBuiltinTerm(tk *Token) (inst *term) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func evalBuiltin(ctx ExprContext, self *term) (v any, err error) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
if isList(rightValue) {
|
if isList(childValue) {
|
||||||
list, _ := rightValue.([]any)
|
list, _ := childValue.(*ListType)
|
||||||
for i, moduleSpec := range list {
|
it := NewFlatArrayIterator(*list)
|
||||||
|
for moduleSpec, err1 := it.Next(); err1 == nil; moduleSpec, err1 = it.Next() {
|
||||||
if module, ok := moduleSpec.(string); ok {
|
if module, ok := moduleSpec.(string); ok {
|
||||||
if ImportInContext(ctx, module) {
|
if ImportInContext(ctx, module) {
|
||||||
count++
|
count++
|
||||||
@ -35,15 +37,15 @@ func evalBuiltin(ctx ExprContext, self *term) (v any, err error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if isString(rightValue) {
|
} else if isString(childValue) {
|
||||||
module, _ := rightValue.(string)
|
module, _ := childValue.(string)
|
||||||
count, err = ImportInContextByGlobPattern(ctx, module)
|
count, err = ImportInContextByGlobPattern(ctx, module)
|
||||||
} else {
|
} else {
|
||||||
err = self.errIncompatibleType(rightValue)
|
err = self.errIncompatibleType(childValue)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
v = count
|
v = count
|
||||||
|
Loading…
Reference in New Issue
Block a user