Skip to content

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

Closed

Description

@vicuna

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

Activity

  1. vicuna commented on Nov 28, 2017

    @vicuna
    Author

    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.

  2. vicuna commented on Nov 29, 2017

    @vicuna
    Author

    Comment author: @alainfrisch

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

  3. vicuna commented on Nov 29, 2017

    @vicuna
    Author

    Comment author: @alainfrisch

    #1495

  4. vicuna commented on Nov 30, 2017

    @vicuna
    Author

    Comment author: @gasche

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

  5. vicuna commented on Dec 5, 2017

    @vicuna
    Author

    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions