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

The compiler does not unbox a type which can not contain a float value #7532

Closed
vicuna opened this issue May 11, 2017 · 1 comment
Closed

Comments

@vicuna
Copy link

vicuna commented May 11, 2017

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.

@vicuna
Copy link
Author

vicuna commented May 11, 2017

Comment author: @gasche

It is an unfortunate restriction of the current unboxed analysis that mutually-recursive types are not well supported. This has been previously reported at

#7364

so I will redirect the conversation there to avoid splits. Thanks for the report!

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