From 07841180bc8883689d8c46adaed6919eb9cc43b0 Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Wed, 21 Aug 2024 11:17:02 +0200 Subject: [PATCH] fix(engine/iterators): support `into_iter` on arrays --- engine/lib/phases/phase_functionalize_loops.ml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/lib/phases/phase_functionalize_loops.ml b/engine/lib/phases/phase_functionalize_loops.ml index 35591e89f..07b010714 100644 --- a/engine/lib/phases/phase_functionalize_loops.ml +++ b/engine/lib/phases/phase_functionalize_loops.ml @@ -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 { @@ -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 @@ -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