Skip to content
Success

Changes

Summary

  1. Add the approx flag to merging of module constraints (details)
  2. Add a [merge_type_approx] for approximation of type constraints (details)
  3. Add tests for module and type constraints during approximation (details)
  4. Update Changelog (details)
  5. Add another test for destructive type constraints approximation (details)
  6. Address review comments on #14100 (details)
  7. Update Changelog (details)
Commit 4a034852ad619b353f2fade2822f875e583545b6 by clement.blaudeau
Add the approx flag to merging of module constraints

- While module types constraints were using the [approx] flag to disable
equivalence checking when merging, module constraints were only checked for
cyclicity. Now, both use the same logic: the constraints is approximated and
then merged in approx mode, where no equivalence check is done. It computes a
better skeleton for the approximated signature, as the destructive substitutions
are correctly removing the fields.

- Add tests borrowed (and adapted) from
https://github.com/oxcaml/oxcaml/pull/4121

- This commit changes the [lookup_module_path ~load:false] for [lookup_module],
where the load flag is not set to false. I should not have much impact for
well-typed programs, as the loading would happen after the approximation phase
anyway.
The file was modifiedtyping/typemod.ml (diff)
The file was addedtestsuite/tests/typing-recmod/regression_destructive_subst.ml
Commit 971d0b59c732bd6778b79f10b3f62e5e0ebe4d67 by clement.blaudeau
Add a [merge_type_approx] for approximation of type constraints

This commit introduces a new function to specifically deal with merging type
constraints in approximation mode:
- destructive constraints actually remove the constrained field, to prevent
incorrect approximation (specifically, incorrect shadowing)
- non-destructive constraints are treated as an identity patch, where the
constrained field is replaced by itself. This allows us to reuse the normal
merging infrastructure and fail early in case of ill-formed constraints where
the field is not present (other forms of ill-formedness are caught later)

The [post_process] function is made aware of the approximation flag to disable
wellformedness checks
The file was modifiedtyping/typemod.ml (diff)
Commit 9f6407a56d0c5c837b7b502107b937b54554981b by clement.blaudeau
Add tests for module and type constraints during approximation
The file was modifiedtestsuite/tests/typing-modules/merge_constraint.ml (diff)
The file was modifiedChanges (diff)
Commit 74d169331120a74c9e2a76eb80d7c9a42a293201 by clement.blaudeau
Add another test for destructive type constraints approximation
The file was modifiedtestsuite/tests/typing-modules/merge_constraint.ml (diff)
Commit 3114cddc8b4bdd717aa98f0fd0a6a4fc7fdb09b8 by clement.blaudeau
Address review comments on #14100

- Factor out computation of the [destructive] flag for constraints between
merging in normal and approximation modes

- Fix typos in test descriptions

- Add test that ghost items are not affected by constraints

- Update Changelog
The file was modifiedtyping/typemod.ml (diff)
The file was modifiedtestsuite/tests/typing-modules/merge_constraint.ml (diff)
The file was modifiedChanges (diff)
The file was modifiedChanges (diff)