Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error with recursive modules #6572

vicuna opened this issue Sep 22, 2014 · 2 comments


None yet
2 participants
Copy link

commented Sep 22, 2014

Original bug ID: 6572
Reporter: acieroid
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:34:52Z)
Resolution: fixed
Priority: normal
Severity: minor
OS: Linux 3.14.18
Version: 4.02.0+beta1 / +rc1
Fixed in version: 4.02.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @hcarty

Bug description

Code involving recursive modules can make the compiler crash

Steps to reproduce

Minimal example to reproduce (use batteries' BatSet):

module rec A : Set.OrderedType = struct
type t = int
let compare =
and B : BatSet.S = struct
module C = BatSet.Make(A)
include C

Compile with ocamlfind ocamlc -c -package batteries -o foo.cmo, which produces the following error:


Fatal error: Bytegen.comp_expr: var C_1386
Fatal error: exception Misc.Fatal_error

Additional information

  • Using OCaml's Set instead of BatSet makes the bug disappear
    • Replacing the B module definition from struct ... end to BatSet.Make(A) also makes the bug disappear
    • As this example doesn't actually need recursive modules, switching to normal modules also makes the bug disappear
    • OCaml version is 4.02 (worked fine on 4.01)
    • Batteries version is latest commit on master branch

This comment has been minimized.

Copy link

commented Sep 22, 2014

Comment author: @yallop

Here's a self-contained example:

module type S =
module M : sig val f : unit -> unit end

module Make (X : sig end) =
module M = struct let f () = () end

module rec A : sig end =
and B : S =
module C = Make(A)
include C


This comment has been minimized.

Copy link

commented Sep 22, 2014

Comment author: @garrigue

Fixed in 4.02 at revision 15298.

Thank you very much for this report.
There was something fishy in Translmod.transl_structure
(some parameter was ignored), but I couldn't find a
counterexample. Thanks to this one, the code seems now

@vicuna vicuna closed this Dec 7, 2016

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.