You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1695 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Some problems using variants in compilation mode:
let l = [B] @ [A];;
val l : _[> A | B] list = [B; A]
is what I am expecting in the top level loop
but the compilation with ocamlc give:
The type of this expression, _[> A | B] list,
contains type variables that cannot be generalized
Is it normal?
If yes, is there some documentation?
The text was updated successfully, but these errors were encountered:
The type of this expression, _[> A | B] list,
contains type variables that cannot be generalized
Is it normal?
If yes, is there some documentation?
This is perfectly normal: the _ in the above type denotes a
non-generalizable type variable in the type of l. This is allowed at
toplevel, but not in compiled modules, if you don't provide a .mli.
For documentation on non-generalizable type variables, look the FAQ
about "value restriction".
However, there is a good news: in the next version of ocaml, the above
example would avoid the value restriction, and you would get a type
without _, and as result no problem with compilation.
Original bug ID: 1695
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Some problems using variants in compilation mode:
let l = [
B] @ [
A];;val l : _[>
A |
B] list = [B;
A]is what I am expecting in the top level loop
but the compilation with ocamlc give:
The type of this expression, _[>
A |
B] list,contains type variables that cannot be generalized
Is it normal?
If yes, is there some documentation?
The text was updated successfully, but these errors were encountered: