Skip to content

Commit f4c4a7f

Browse files
committed
QWE
1 parent ee5f249 commit f4c4a7f

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

compiler/lib/flow.ml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,17 @@ let the_shape_of ~return_values ~pure info x =
516516
Shape.Function { arity; pure; res = Top "unk" }
517517
with _ -> Top "other")
518518
| Expr (Apply { f; args; _ }) -> (
519-
match loop info f (Var.Set.add f acc) with
519+
let shape = loop info f (Var.Set.add f acc) in
520+
let rec loop n' shape =
521+
match shape with
520522
| Shape.Function { arity = n; pure; res } ->
521-
let diff = n - List.length args in
522-
if diff > 0
523-
then Shape.Function { arity = diff; pure; res }
524-
else if diff = 0
525-
then res
526-
else Shape.Top "apply"
527-
| Shape.Block _ | Shape.Top _ -> Shape.Top "apply2")
523+
if n = n' then res
524+
else if n' < n
525+
then Shape.Function { arity = n - n'; pure; res }
526+
else loop (n' - n) res
527+
| Shape.Block _ | Shape.Top _ -> Shape.Top "apply2"
528+
in
529+
loop (List.length args) shape)
528530
| _ -> Shape.Top "other"))
529531
(Top "init")
530532
(fun u v -> merge u v)

compiler/lib/shape.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ module State = struct
149149
| Some (Top _ | Function _) -> ()
150150
| Some (Block l) -> assign target (List.nth l offset)
151151

152-
let get x = Code.Var.Hashtbl.find_opt t.table x
153-
154152
let mem x = BitSet.mem t.cache (Code.Var.idx x)
155153

154+
let get x = if mem x then Code.Var.Hashtbl.find_opt t.table x
155+
else None
156+
157+
156158
let is_pure_fun x =
157159
match Code.Var.Hashtbl.find_opt t.table x with
158160
| None -> false

0 commit comments

Comments
 (0)