Skip to content

Commit

Permalink
chore: don't rebind variable in ir_passes/await.ml (#4655)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif authored Aug 10, 2024
1 parent 5bfe4db commit 9b67c0c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ir_passes/await.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b67c0c

Please sign in to comment.