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
It is an unfortunate restriction of the current unboxed analysis that mutually-recursive types are not well supported. This has been previously reported at
Original bug ID: 7532
Reporter: Matthieu Lemerre
Assigned to: @gasche
Status: resolved (set by @gasche on 2017-05-11T17:56:39Z)
Resolution: duplicate
Priority: normal
Severity: major
Platform: Linux
OS: Debian
Version: 4.04.0
Category: typing
Duplicate of: #7364
Monitored by: @yallop
Bug description
The compiler fails at detecting that a type cannot contain a float value on a recursive type definition, and fails with the following error:
Error: This type cannot be unboxed because
it might contain both float and non-float values.
You should annotate it with [@@ocaml.boxed].
If the type definition is not recursive, the type is correctly detected as unboxable.
Steps to reproduce
ocamlc on the following program. Reports an error with opam switch 4.04.0+fp and latest trunk (908a381)
type x
type y
type 'a t =
| X: {id: int} -> x t
| Y: {id: int} -> y t
and any = Any: 'a t -> any [@@unboxed]
Additional information
With the following program, everything works as intended; the only difference is that the type definition is not recursive:
type x
type y
type 'a t =
| X: {id: int} -> x t
| Y: {id: int} -> y t
type any = Any: 'a t -> any [@@unboxed]
Of course I actually need a recursive version, where X contains an "any" field.
The text was updated successfully, but these errors were encountered: