When loading up code in utop
(or dune utop
) and printing any data constructor like Bin.Stop
with #show Bin.Stop;;
I get a crash.
utop # #show Bin.Stop;;
>> Fatal error: Ident.rename Bin.nat
Fatal error: exception Misc.Fatal_error
~ via v4.12.0 took 4m41s
❯
While ocaml
does not crash.
Is this a bug or is there an obvious reason why that would be illegal ?
(* SOTypeLevelNat.ml *)
module Bin : sig
type stop = Qasdpaokdsap
type 'a zero = Sasddkasdo
type 'a one = Zoldjsfoij
type _ nat =
| Stop : 'stop nat
| Times2 : 'n nat -> 'n zero nat
| Times2Plus1 : 'n nat -> 'n one nat
end = struct
type stop = Qasdpaokdsap
type 'a zero = Sasddkasdo
type 'a one = Zoldjsfoij
type _ nat =
| Stop : 'stop nat
| Times2 : 'n nat -> 'n zero nat
| Times2Plus1 : 'n nat -> 'n one nat
end
utop # #use "SOTypeLevelNat.ml";;
module Peano :
sig
type 'a s = S
type z = Z
type 'n nat = Zero : 'a nat | Succ : 'n nat -> 'n s nat
end
module Bin :
sig
type stop = Qasdpaokdsap
type 'a zero = Sasddkasdo
type 'a one = Zoldjsfoij
type _ nat =
Stop : 'stop nat
| Times2 : 'n nat -> 'n zero nat
| Times2Plus1 : 'n nat -> 'n one nat
end
printing a type, say, the nat
works just fine
utop # #show Bin.nat;;
type nonrec _ nat =
Stop : 'stop Bin.nat
| Times2 : 'n Bin.nat -> 'n Bin.zero Bin.nat
| Times2Plus1 : 'n Bin.nat -> 'n Bin.one Bin.nat
Fatal errors with toplevel directives that happen in
utop
and notocaml
are bugs inutop
.Indeed,
utop
partially reimplements the driver logic of the OCaml REPL and it can happen that utop's code ends up slightly out-of-date with the underlying OCaml's compiler libraries.Please report issues like this at: https://github.com/ocaml-community/utop/issues