-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new attribute for allowing any mode crossing (#3424)
* Add a new attribute for allowing any mode crossing Replace the [@@unsafe_allow_any_kind_in_{impl,intf}] attributes with a new [@@unsafe_allow_any_mode_crossing] attribute. This is different in that it: 1. Works on the type declaration, not the inclusion check, so is more powerful - it can be used to illegally mode cross types defined in the same module, or illegally mode cross non-abstract types in interfaces. The latter especially is necessary to fully subsume -allow-illegal-crossing in stdlib 2. Only allows changing the modal bounds of a kind, not the layout - it's unclear that anyone should ever want to unsafely change the layout of a kind; I personally can't think of any sound reason to do so. Some [past discussion][0] on the specific syntax for this attribute suggested specifying the bounds directly on the attribute, rather than using the jkind annotation, but I and others feel reasonably strongly that this way of doing things is a better design for the sake of consistency. [0]: #3385 (comment) * Print the [@@unsafe_allow_any_mode_crossing] attribute in outcomes For types that set it, or *would have* set it (eg because the whole compilation unit set -allow-illegal-crossing) * Track unsafe_mode_crossing in type_kind Add a field to (the relevant variants of) type_kind, which tracks the (extended) modal upper bounds of a kind introduced by the usage of the [@@unsafe_allow_any_mode_crossing] attribute. This allows us to check this in eg the inclusion check, and forbid extending the upper bounds of a type /only/ by constraining it to a signature. Also, this moves more towards a world where `decl.type_jkind` is "morally" just a memo of the type's kind, where everything about the kind /could/ ostensibly be computed by looking at the type_kind. A few extra test cases checking that we cant do this have also been added to `allow_any.ml` * Be more strict about unsafe mode crossing in inclusion Specifically, require strict equality of bounds, and the attribute present on both sides.
- Loading branch information
1 parent
069d613
commit 8935997
Showing
31 changed files
with
582 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.