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

Closed
vicuna opened this issue Sep 22, 2014 · 2 comments
Closed

Fatal error with recursive modules #6572

vicuna opened this issue Sep 22, 2014 · 2 comments
Assignees
Labels

Comments

@vicuna
Copy link

@vicuna vicuna 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 = Pervasives.compare
end
and B : BatSet.S = struct
module C = BatSet.Make(A)
include C
end

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

C/1386

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
@vicuna
Copy link
Author

@vicuna vicuna commented Sep 22, 2014

Comment author: @yallop

Here's a self-contained example:

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

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

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

@vicuna
Copy link
Author

@vicuna vicuna 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
correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants