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
{{ message }}
Repository navigation
[@@unboxed] for records with 1 polymorphic field #7682
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.
Activity
vicuna commentedon 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 commentedon Nov 29, 2017
Comment author: @alainfrisch
I believe Ctype.get_unboxed_type_representation should traverse Tpoly. Working on a fix.
vicuna commentedon Nov 29, 2017
Comment author: @alainfrisch
#1495
vicuna commentedon Nov 30, 2017
Comment author: @gasche
The issue was fixed by merging Alain Frisch's patch. Thanks for the testing and report!
vicuna commentedon Dec 5, 2017
Comment author: disteph
Thank you both for your very prompt response!