Skip to content

Commit cd4644c

Browse files
authored
flambda-backend: Prevent fatal errors related to regions (#2096)
1 parent 45457d9 commit cd4644c

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(* TEST *)
2+
3+
type (_, _) eq = Eq : ('a, 'a) eq
4+
5+
let[@inline always] cast (type a b) (x : a) (Eq : (a, b) eq) : b = x
6+
7+
let test (f : local_ 'a -> local_ 'b) (eq : (local_ 'a -> local_ 'b, 'a -> 'b) eq) (x : 'a) : 'b =
8+
(cast f eq) x
9+
10+
type 'a box = Box of 'a
11+
12+
let localf : (local_ 'a -> local_ 'a box) = fun x -> exclave_ (local_ (Box x))
13+
14+
let g eq x = test localf eq x

testsuite/tests/typing-local/local_gadt.reference

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(* TEST *)
2+
3+
type 'a box = Box of 'a
4+
module X : sig
5+
val f : int -> string -> local_ int box
6+
end = struct
7+
let[@inline never] f x y = exclave_ (local_ (Box x))
8+
end
9+
10+
let[@inline always] h x = x
11+
12+
let g a = (h X.f) a

testsuite/tests/typing-local/partial_app_bug.reference

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(* TEST *)
2+
3+
type 'a box = Box of 'a
4+
5+
let[@inline never] f x y z =
6+
match x, y, z with Box x, Box y, Box z -> x + y + z
7+
8+
type t = int box -> int box -> int
9+
let[@inline always] h x = x
10+
let g = (h f :> int box -> local_ t)
11+
12+
let[@inline never] go a b c =
13+
let local_ g1 = (g a) in
14+
let g2 = (g1 b) in
15+
g2 c
16+
17+
let[@inline never] test () =
18+
Format.eprintf "%d@." (go (Box 1) (Box 2) (Box 3))
19+
20+
let () = test ()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6

0 commit comments

Comments
 (0)