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

Recursive modules can be used to break type safety #4336

Closed
vicuna opened this issue Jul 6, 2007 · 1 comment
Closed

Recursive modules can be used to break type safety #4336

vicuna opened this issue Jul 6, 2007 · 1 comment
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 6, 2007

Original bug ID: 4336
Reporter: dnoblet
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2007-10-26T15:44:42Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.10.0
Category: ~DO NOT USE (was: OCaml general)
Related to: #4450 #4709
Monitored by: lavi "Julien Signoles" n8gray @oandrieu @yakobowski berke @alainfrisch @mmottl

Bug description

The following program compiles and runs using OCaml 3.10.0:

module type ASig = sig type a val a:a val print:a -> unit end
module type BSig = sig type b val b:b val print:b -> unit end

module A = struct type a = int let a = 0 let print = print_int end
module B = struct type b = float let b = 0.0 let print = print_float end

module MakeA (Empty:sig end) : ASig = A
module MakeB (Empty:sig end) : BSig = B

module
rec NewA : ASig = MakeA (struct end)
and NewB : BSig with type b = NewA.a = MakeB (struct end)

let _ =
NewA.print NewB.b;
NewB.print NewA.a

The problem is, of course, that type A.a = int and type B.b = float; so, it seems like the compiler should complain when I try to construct module NewB with the (incorrect) type contraint "BSig with type b = NewA.a".

-David

@vicuna
Copy link
Author

vicuna commented Oct 26, 2007

Comment author: @xavierleroy

The check 'signature of implementation matches declared signature' was performed in the wrong typing environment. This is now fixed in the 3.10 CVS branch.

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