Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zap modalities to identity for mli-less files #3282

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

riaqn
Copy link
Contributor

@riaqn riaqn commented Nov 15, 2024

For .ml files without a corresponding .mli, previously we thought the generated .cmi will only be on the LHS of inclusion check, and therefore it's always better to infer the strongest modalities. This is obviously wrong, because another module could invoke module type of on the .cmi and use it on RHS of inclusion check. This has broken legacy code in practice.

This PR therefore zaps modalitites to identity, which is more legacy compatible.

Side note: In the future we should add two flags to override the default behavior:

  • one flag on mli-less files, to indicate the direction of zapping when exporting cmx. It should error if .mli exists:
[@@@zap_modalities_to_floor]
(rest of the ml file)
  • One flag on module type of, to indicate the direction of zapping when calculating the module type. It should error if the module already has a user-annotated module type:
module M = struct
  ...
end

module type S = module type of M [@@zap_modalities_to_floor]

@riaqn riaqn marked this pull request as ready for review November 15, 2024 20:50
@@ -1,4 +1,4 @@
File "use_portable.ml", line 3, characters 22-38:
3 | let () = portable_use Maybe_portable.f
^^^^^^^^^^^^^^^^
Error: This value is nonportable but expected to be portable.
Error: This value is "nonportable" but expected to be "portable".
Copy link
Contributor Author

@riaqn riaqn Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated to the PR. The test was out-of-sync, because val_modalities_floor.ml was skipped by make test. I have made it not skipped, by re-ordering things in that file so it starts with (* TEST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant