Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-3954] Treat ArrayVar.foreach index as int #4193

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions reflex/vars/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def foreach(self, fn: Any):
function_var = ArgsFunctionOperation.create(tuple(), return_value)
else:
# generic number var
number_var = Var("").to(NumberVar)
number_var = Var("").to(NumberVar, int)

first_arg_type = self[number_var]._var_type

Expand All @@ -1167,7 +1167,10 @@ def foreach(self, fn: Any):
_var_type=first_arg_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)

Expand Down
Loading