ocaml-flambda / flambda-backend

The Flambda backend project for OCaml
92 stars 65 forks source link

Allow `Maybe_null` jkinds in more places #2747

Open dkalinichenko-js opened 1 week ago

dkalinichenko-js commented 1 week ago

Make most jkinds created from sort variables Maybe_null. This allows types like or_null in function arguments, function results, record fields and so on. This excludes:

Accept value_or_null for the V1 safety check, for the separability check, for tuple elements, for structure elements, and for polymorphic variant fields.

Require array type parameters to be non-null.

Hide value_or_null and any_non_null from users if the layouts extension is below Alpha, replacing them with value or any in the compiler output.

Convert any annotations to any_non_null if the layouts extension is below Alpha for compatibility with existing code using arrays.

Split some tests into alpha and non-alpha versions due to different printing behavior.

Tests in typing-layouts-or-null cover some changes in this PR, but not all. More tests will be added in the PR implementing the or_null type.