File: bug13448bis.ml

package info (click to toggle)
js-of-ocaml 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 37,932 kB
  • sloc: ml: 135,957; javascript: 58,364; ansic: 437; makefile: 422; sh: 12; perl: 4
file content (26 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(* TEST *)

(* Regression test for #13448, see explanations in #13449.
   Another variant of the bug, with GADTs instead of flat float arrays *)
type _ t =
  | Int32 : int32 t
  | Float : float t

let constant = 42l

let[@inline always] default : type a . a t -> a = function
  | Float ->
     (* We want an expression that starts
        with box<float>(...). *)
     exp 0.
  | Int32 ->
     (* We want an expression that does not start
        with box<int32>(...). *)
     Sys.opaque_identity constant

let () =
  (* we use [opaque_identity] so that [default gadt] is not
     reduced at compile-time. *)
  let gadt = Sys.opaque_identity Int32 in
  let n = default gadt in
  assert (n = constant)