Skip to content

Add option to compile code with polymorhic empty arrays #4189

@flash-gordon

Description

@flash-gordon

This was discussed on the discord chat.
Recently, it was discovered that Js.Array.push leads to unsoundness when combined with polymorphic empty arrays ([||] has type 'a array in OCaml). The issue was reported in #4087 and was promptly fixed in #4090 which made empty arrays weakly polymorphic. It restored soundness but broke some existing code relying on the previous behavior (see Risto-Stevcev/bastet#20).

While there are discussions on how to approach the breakage, I suggest adding a compilation flag making existing code compilable within the BS 7.x series. Something like -bs-unsafe-empty-array. In fact, it was suggested by @bobzhang; I'm just filing an issue so it won't get lost.

I want to add there are different opinions on whether it's a good precedent to diverge from the native behavior but at least having a compilation flag will unblock me personally and I'm pretty sure a few other people too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions