at operator return -1 when fails in lists and arrays; insert operators (<< and >>) changes che container if it is a variable
This commit is contained in:
+4
-1
@@ -36,6 +36,7 @@ func evalAt(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
v = int64(-1) // default value if not found
|
||||
if array.IsArray(rightValue) {
|
||||
a, _ := rightValue.(*array.ArrayType)
|
||||
if index := a.IndexDeepSameCmp(leftValue); index >= 0 {
|
||||
@@ -45,14 +46,16 @@ func evalAt(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
||||
dict, _ := rightValue.(*dict.DictType)
|
||||
if k, exists := dict.FindKey(leftValue); exists {
|
||||
v = k
|
||||
} else {
|
||||
v = nil
|
||||
}
|
||||
|
||||
} else if list.IsLinkedList(rightValue) {
|
||||
ls, _ := rightValue.(*list.LinkedList)
|
||||
if index := ls.Index(leftValue); index >= 0 {
|
||||
v = index
|
||||
}
|
||||
} else {
|
||||
v = nil
|
||||
err = opTerm.ErrIncompatibleTypes(leftValue, rightValue)
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user