We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 74e6758 commit 36bce82Copy full SHA for 36bce82
testsuite/tests/mixed-blocks/variant_unboxing.ml
@@ -0,0 +1,28 @@
1
+(* TEST
2
+ flags = "-extension layouts_beta";
3
+ native;
4
+*)
5
+
6
+(* Unboxing of variants with mixed constructors *)
7
8
+type t =
9
+ | Const_t
10
+ | Boxed of Float.t
11
12
+type u =
13
+ | Const_u
14
+ | Unboxed of float#
15
16
+external unbox : float -> float# = "%unbox_float"
17
18
+let t_to_u (t : t) : u =
19
+ match t with
20
+ | Const_t -> Const_u
21
+ | Boxed field -> Unboxed (unbox field)
22
+;;
23
24
+let f t =
25
+ (* The result of [t_to_u] is speculatively unboxed *)
26
+ let _ = t_to_u t in
27
+ ()
28
0 commit comments