Skip to content

Commit 6616a8c

Browse files
authored
Merge pull request #1732 from cryspen/accept-loop-without-mutation
Accept loops without mutation.
2 parents 0882dfd + 0175a75 commit 6616a8c

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

engine/lib/phases/phase_functionalize_loops.ml

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,7 @@ struct
205205
let module M = UB.M in
206206
let module MS = (val M.make span) in
207207
match expr.e with
208-
| Loop
209-
{
210-
body;
211-
kind = ForLoop { it; pat; _ };
212-
state = Some _ as state;
213-
control_flow;
214-
_;
215-
}
216-
| Loop
217-
{
218-
body;
219-
kind = ForLoop { it; pat; _ };
220-
state;
221-
control_flow = Some (BreakOrReturn, _) as control_flow;
222-
_;
223-
} ->
208+
| Loop { body; kind = ForLoop { it; pat; _ }; state; control_flow; _ } ->
224209
let bpat, init =
225210
match state with
226211
| Some { bpat; init; _ } -> (dpat bpat, dexpr init)
@@ -264,22 +249,8 @@ struct
264249
(fold, [ it; init; fn ])
265250
in
266251
UB.call f args span (dty span expr.typ)
267-
| Loop
268-
{
269-
body;
270-
kind = WhileLoop { condition; _ };
271-
state = Some _ as state;
272-
control_flow;
273-
_;
274-
}
275-
| Loop
276-
{
277-
body;
278-
kind = WhileLoop { condition; _ };
279-
state;
280-
control_flow = Some (BreakOrReturn, _) as control_flow;
281-
_;
282-
} ->
252+
| Loop { body; kind = WhileLoop { condition; _ }; state; control_flow; _ }
253+
->
283254
let bpat, init =
284255
match state with
285256
| Some { bpat; init; _ } -> (dpat bpat, dexpr init)
@@ -345,9 +316,6 @@ struct
345316
UB.call fold_operator
346317
[ condition; invariant; variant; init; body ]
347318
span (dty span expr.typ)
348-
| Loop { state = None; _ } ->
349-
Error.unimplemented ~issue_id:405 ~details:"Loop without mutation"
350-
span
351319
| Loop _ ->
352320
Error.unimplemented ~issue_id:933 ~details:"Unhandled loop kind" span
353321
| [%inline_arms "dexpr'.*" - Loop - Break - Continue - Return] ->

0 commit comments

Comments
 (0)