diff --git a/compiler/lib/flow.ml b/compiler/lib/flow.ml index df14ea4e50..8ce118f14a 100644 --- a/compiler/lib/flow.ml +++ b/compiler/lib/flow.ml @@ -401,24 +401,21 @@ let rec the_shape_of info x = get_approx info (fun x -> - if Var.ISet.mem info.info_possibly_mutable x - then Shape.Top "possibly_mutable" - else - match Shape.get x with - | Some shape -> shape - | None -> ( - match info.info_defs.(Var.idx x) with - | Expr (Block (_, a, _, Immutable)) -> - Shape.Block (List.map ~f:(the_shape_of info) (Array.to_list a)) - | Expr (Closure (l, _)) -> - Shape.Function { arity = List.length l; pure = false; res = Top "unk" } - | Expr (Special (Alias_prim name)) -> ( - try - let arity = Primitive.arity name in - let pure = Primitive.is_pure name in - Shape.Function { arity; pure; res = Top "unk" } - with _ -> Top "other") - | _ -> Shape.Top "other")) + match Shape.get x with + | Some shape -> shape + | None -> ( + match info.info_defs.(Var.idx x) with + | Expr (Block (_, a, _, Immutable)) -> + Shape.Block (List.map ~f:(the_shape_of info) (Array.to_list a)) + | Expr (Closure (l, _)) -> + Shape.Function { arity = List.length l; pure = false; res = Top "unk" } + | Expr (Special (Alias_prim name)) -> ( + try + let arity = Primitive.arity name in + let pure = Primitive.is_pure name in + Shape.Function { arity; pure; res = Top "unk" } + with _ -> Top "other") + | _ -> Shape.Top "other")) (Top "init") (fun _u _v -> Shape.Top "merge") x diff --git a/compiler/tests-full/stdlib.cma.expected.js b/compiler/tests-full/stdlib.cma.expected.js index 92f9855753..013a1ecd10 100644 --- a/compiler/tests-full/stdlib.cma.expected.js +++ b/compiler/tests-full/stdlib.cma.expected.js @@ -305,7 +305,7 @@ //# unitInfo: Provides: Stdlib //# unitInfo: Requires: CamlinternalFormatBasics -//# shape: Stdlib:[F(1),F(1),N,N,N,N,N,N,N,N,N,N,N,N,N,F(2),F(2),F(1),N,N,F(1),N,N,N,N,N,N,F(2),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(2),N,N,N,F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(3),F(1),N,F(2),F(2),F(2),F(4),F(4),F(2),F(2),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(1),F(1),F(3),F(1),F(1),F(4),F(4),F(2),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),N,F(1),F(2),F(1),F(1),F(1),F(4),N,N] +//# shape: Stdlib:[F(1),F(1),N,N,N,N,N,N,N,N,N,N,N,N,N,F(2),F(2),F(1),N,N,F(1),N,N,N,N,N,N,F(2),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(2),N,N,N,F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(3),F(1),F(1),F(2),F(2),F(2),F(4),F(4),F(2),F(2),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(1),F(1),F(3),F(1),F(1),F(4),F(4),F(2),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),N,F(1),F(2),F(1),F(1),F(1),F(4),F(1),N] (function (globalThis){ "use strict"; @@ -1634,7 +1634,7 @@ //# unitInfo: Provides: Stdlib__Seq //# unitInfo: Requires: CamlinternalLazy, Stdlib, Stdlib__Atomic, Stdlib__Lazy -//# shape: Stdlib__Seq:[F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(2),F(3),F(4),F(3),F(3),F(3),F(3),N,F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(3),F(2),F(3),F(3),F(3),F(2),F(2),F(3),F(3),F(3),F(1),N,F(1),F(2),F(3),F(2),F(3),F(3),F(3),F(4),F(3),F(4),F(2),F(3),F(1),F(1),F(2),F(2),F(1),F(1),F(2)] +//# shape: Stdlib__Seq:[F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(2),F(3),F(4),F(3),F(3),F(3),F(3),F(1),F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(3),F(2),F(3),F(3),F(3),F(2),F(2),F(3),F(3),F(3),F(1),N,F(1),F(2),F(3),F(2),F(3),F(3),F(3),F(4),F(3),F(4),F(2),F(3),F(1),F(1),F(2),F(2),F(1),F(1),F(2)] (function (globalThis){ "use strict"; @@ -21372,8 +21372,7 @@ ? empty_backtrace : /*<>*/ caml_get_exception_raw_backtra(0); /*<>*/ try{ - /*<>*/ /*<>*/ caml_call1 - (Stdlib[103], 0); + /*<>*/ Stdlib[103].call(null, 0); } catch(_C_){} /*<>*/ try{ @@ -23038,7 +23037,7 @@ //# unitInfo: Provides: Stdlib__Hashtbl //# unitInfo: Requires: Stdlib, Stdlib__Array, Stdlib__Atomic, Stdlib__Domain, Stdlib__Int, Stdlib__Random, Stdlib__Seq, Stdlib__String, Stdlib__Sys -//# shape: Stdlib__Hashtbl:[N,N,N,N,F(3),F(2),F(2),F(2),F(2),F(2),F(3),N,N,N,N,F(1),F(1),F(2),N,N,N,N,F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)] +//# shape: Stdlib__Hashtbl:[F(2),F(1),F(1),F(1),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(2),F(3),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)] (function (globalThis){ "use strict"; @@ -24079,7 +24078,7 @@ //# unitInfo: Provides: Stdlib__Weak //# unitInfo: Requires: Stdlib, Stdlib__Array, Stdlib__Int, Stdlib__Obj, Stdlib__Sys -//# shape: Stdlib__Weak:[F(1),N,N,F(2),F(2),F(2),F(4),F(5),F(1)] +//# shape: Stdlib__Weak:[F(1),F(1),F(3),F(2),F(2),F(2),F(4),F(5),F(1)] (function (globalThis){ "use strict"; @@ -24632,7 +24631,7 @@ //# unitInfo: Provides: Stdlib__Format //# unitInfo: Requires: CamlinternalFormat, Stdlib, Stdlib__Array, Stdlib__Buffer, Stdlib__Bytes, Stdlib__Domain, Stdlib__Int, Stdlib__List, Stdlib__Queue, Stdlib__Seq, Stdlib__Stack, Stdlib__String -//# shape: Stdlib__Format:[F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),N,F(1),F(3),F(2),F(3),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(3),F(2),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),N,F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(1),N,F(1),N,F(1),F(1),N,F(1),N,F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(1),F(2),F(1),F(5),F(4),F(4),F(4),F(2),F(4),F(4),F(4),F(1),F(1),F(1),F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2)] +//# shape: Stdlib__Format:[F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(3),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(3),F(2),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),N,F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(1),N,F(1),N,F(1),F(1),N,F(1),N,F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(1),F(2),F(1),F(5),F(4),F(4),F(4),F(2),F(4),F(4),F(4),F(1),F(1),F(1),F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2)] (function (globalThis){ "use strict"; @@ -28906,7 +28905,7 @@ //# unitInfo: Provides: CamlinternalOO //# unitInfo: Requires: Stdlib, Stdlib__Array, Stdlib__List, Stdlib__Map, Stdlib__Obj, Stdlib__Sys -//# shape: CamlinternalOO:[N,F(1),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(4),F(1),F(2),N,F(1),F(1),F(6),F(2),F(3),F(1),F(1),F(1),F(2),F(2),F(3),F(2),F(2),N,F(1)] +//# shape: CamlinternalOO:[F(1),F(1),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(4),F(1),F(2),N,F(1),F(1),F(6),F(2),F(3),F(1),F(1),F(1),F(2),F(2),F(3),F(2),F(2),N,F(1)] (function (globalThis){ "use strict"; @@ -33108,7 +33107,7 @@ //# unitInfo: Provides: Stdlib__MoreLabels //# unitInfo: Requires: Stdlib__Hashtbl, Stdlib__Map, Stdlib__Set -//# shape: Stdlib__MoreLabels:[[N,N,N,N,F(3),F(2),F(2),F(2),F(2),F(2),F(3),N,N,N,N,F(1),F(1),F(2),N,N,N,N,F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)],[F(1)],[F(1)]] +//# shape: Stdlib__MoreLabels:[[F(2),F(1),F(1),F(1),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(2),F(3),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)],[F(1)],[F(1)]] (function (globalThis){ "use strict";