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

[@@unboxed] for records with 1 polymorphic field #7682

Closed
vicuna opened this issue Nov 28, 2017 · 5 comments
Closed

[@@unboxed] for records with 1 polymorphic field #7682

vicuna opened this issue Nov 28, 2017 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Nov 28, 2017

Original bug ID: 7682
Reporter: disteph
Assigned to: @alainfrisch
Status: resolved (set by @gasche on 2017-11-30T10:21:55Z)
Resolution: fixed
Priority: normal
Severity: feature
Platform: Linux
Version: 4.06.0
Fixed in version: 4.07.0+dev/beta2/rc1/rc2
Category: configure and build/install
Monitored by: @gasche

Bug description

The following three lines lead to a compile-time crash

type f = {field: 'a. 'a list} [@@unboxed]
let g = Array.make 10 { field=[] }
let h = g.(5)

The error is
Fatal error: exception File "typing/typeopt.ml", line 98, characters 6-12: Assertion failed

Steps to reproduce

ocamlc bug.ml

where bug is the attached file.

Additional information

I was surprised by the nature of the error. Merlin didn't complain about typing, and the "exception File "typing/typeopt.ml", line 98, characters 6-12: Assertion failed" is not where I would have expected a problem to arise.

If it is a known limitation of unboxing that doesn't marry well with polymorphism in the field type, I would have expected the error to tell me so, while an "Assertion failed" sounds more like a missed case.

It'd be amazing if it did work by just removing the assertion, though. But life is probably not that beautiful.

Reproducible in 4.05.0 (at least).

File attachments

@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: disteph

Also, it's surprising that the first two lines alone compile perfectly well

type f = {field: 'a. 'a list} [@@unboxed]
let g = Array.make 10 { field=[] }

It's really when I access an array cell that the compilation crashes.

@vicuna
Copy link
Author

vicuna commented Nov 29, 2017

Comment author: @alainfrisch

I believe Ctype.get_unboxed_type_representation should traverse Tpoly. Working on a fix.

@vicuna
Copy link
Author

vicuna commented Nov 29, 2017

Comment author: @alainfrisch

#1495

@vicuna
Copy link
Author

vicuna commented Nov 30, 2017

Comment author: @gasche

The issue was fixed by merging Alain Frisch's patch. Thanks for the testing and report!

@vicuna vicuna closed this as completed Nov 30, 2017
@vicuna
Copy link
Author

vicuna commented Dec 5, 2017

Comment author: disteph

Thank you both for your very prompt response!

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