[ENG-3954] Treat ArrayVar.foreach index as int (#4193)
* [ENG-3954] Treat ArrayVar.foreach index as int * foreach: convert return value to a Var When the value returned from the foreach is not hashable (mutable type), then it will raise an exception if it is not first converted to a LiteralVar.
This commit is contained in:
parent
101fb1b540
commit
e14c79d57d
@ -1155,7 +1155,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE]):
|
|||||||
function_var = ArgsFunctionOperation.create(tuple(), return_value)
|
function_var = ArgsFunctionOperation.create(tuple(), return_value)
|
||||||
else:
|
else:
|
||||||
# generic number var
|
# generic number var
|
||||||
number_var = Var("").to(NumberVar)
|
number_var = Var("").to(NumberVar, int)
|
||||||
|
|
||||||
first_arg_type = self[number_var]._var_type
|
first_arg_type = self[number_var]._var_type
|
||||||
|
|
||||||
@ -1167,7 +1167,10 @@ class ArrayVar(Var[ARRAY_VAR_TYPE]):
|
|||||||
_var_type=first_arg_type,
|
_var_type=first_arg_type,
|
||||||
).guess_type()
|
).guess_type()
|
||||||
|
|
||||||
function_var = ArgsFunctionOperation.create((arg_name,), fn(first_arg))
|
function_var = ArgsFunctionOperation.create(
|
||||||
|
(arg_name,),
|
||||||
|
Var.create(fn(first_arg)),
|
||||||
|
)
|
||||||
|
|
||||||
return map_array_operation(self, function_var)
|
return map_array_operation(self, function_var)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user