Skip to content

Commit

Permalink
fix(engine/iterators): support into_iter on arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
W95Psp committed Aug 21, 2024
1 parent 6f72365 commit 0784118
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions engine/lib/phases/phase_functionalize_loops.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct
| StepBy of { n : B.expr; it : iterator }
[@@deriving show]

let rec as_iterator (e : B.expr) : iterator option =
let rec as_iterator' (e : B.expr) : iterator option =
match e.e with
| Construct
{
Expand All @@ -93,6 +93,12 @@ struct
Some (Range { start; end_ })
| _ -> meth_as_iterator e

and as_iterator (e : B.expr) : iterator option =
let result = as_iterator' e in
(* UB.Debug.expr ~label:"as_iterator" e; *)
(* " = " ^ [%show: iterator option] result |> Stdio.prerr_endline; *)
result

and meth_as_iterator (e : B.expr) : iterator option =
let* f, args =
match e.e with
Expand All @@ -112,7 +118,7 @@ struct
then
let* iterable = one_arg () in
match iterable.typ with
| TSlice _ -> Some (Slice iterable)
| TSlice _ | TArray _ -> Some (Slice iterable)
| _ -> as_iterator iterable
else if f_eq Core__iter__traits__iterator__Iterator__enumerate then
let* iterable = one_arg () in
Expand Down

0 comments on commit 0784118

Please sign in to comment.