From 9b67c0ccdea1d02f5e5027f73b7bc15b4ac2c716 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Sat, 10 Aug 2024 03:04:03 +0200 Subject: [PATCH] chore: don't rebind variable in `ir_passes/await.ml` (#4655) --- src/ir_passes/await.ml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ir_passes/await.ml b/src/ir_passes/await.ml index c254b594649..4072af11c75 100644 --- a/src/ir_passes/await.ml +++ b/src/ir_passes/await.ml @@ -245,19 +245,20 @@ and binary context k binE e1 e2 = assert false and nary context k naryE es = - let rec nary_aux vs es = - match es with + let rec nary_aux vs = function | [] -> k -@- naryE (List.rev vs) | [e1] when eff e1 = T.Triv -> (* TBR: optimization - no need to name the last trivial argument *) k -@- naryE (List.rev (t_exp context e1 :: vs)) | e1 :: es -> - match eff e1 with - | T.Triv -> + match eff e1, e1.it with + | _, VarE (Const, _) -> + nary_aux (e1 :: vs) es + | T.Triv, _ -> let v1 = fresh_var "v" (typ e1) in letE v1 (t_exp context e1) (nary_aux (varE v1 :: vs) es) - | T.Await -> + | T.Await, _ -> c_exp context e1 (meta (typ e1) (fun v1 -> nary_aux (varE v1 :: vs) es)) in