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

trunk/4.02 - Unexpected/incorrect "contains type variables that cannot be generalized" #6419

Closed
vicuna opened this issue May 13, 2014 · 3 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented May 13, 2014

Original bug ID: 6419
Reporter: Nick Chapman
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:27:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.02.0+dev
Category: typing
Monitored by: @diml

Bug description

Reproduce using the following 3-line example, build with Jane street's Core library.

open Core.Std
let () = Printf.printf "some unrelated message"
let my_table (: int String.Table.t) = String.Table.of_alist_exn [("OK",0)]

$ ocamlopt -I lib/core_kernel -I lib/core -c cant_generalise.ml

File "cant_generalise.ml", line 3, characters 40-76:
Error: The type of this expression, ('a, int) Core.Std.String.Table.t,
contains type variables that cannot be generalized

The type error is avoided if either:

  • the explicit type annotation is uncommented
  • the unrelated printf line is removed
@vicuna
Copy link
Author

vicuna commented May 13, 2014

Comment author: Nick Chapman

The type error is also avoided by adding the following type annotation
to the printf format string...

let () = Printf.printf ("some unrelated message":(,,_)format)

@vicuna
Copy link
Author

vicuna commented May 14, 2014

Comment author: @garrigue

Somebody forgot to call instance_def...

Fixed in 4.02 branch at revision 14861.

@vicuna
Copy link
Author

vicuna commented May 14, 2014

Comment author: @gasche

PS: the faulty part of the code is now completely gone (use of a nominal type instead of a tuple for format6).

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

No branches or pull requests

2 participants