-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make type annotations to not propagate through merging (#1271)
* First draft of making type not propagating * Consider record types as such whenever possible Before this change, a record literal was considered a record type whenever it met a bunch of conditions AND was used in a type position. This meant that `{foo : Number, bar : String}` was always considered as a normal record (fields without definition) when used in a term position. This was already subtly wrong, because this means for example that `x | {foo : Number}` and `let C = {foo : Number} in x | C` are operationally not equivalent. Now that we've made a stronger distinction between static types and contracts (types don't propagate through merging), then this behavior is just unsound. As per this commit, a record literal is considered a record type whenever it satisfies the syntactic conditions, be it in a type or a term position. Additionally, we've forbidden "mixed" style records, that is record literals that are not a record type, but with fields that have a type annotation and no definition. Beside being meaningless, they can be deceiving, and are most often an error or a confusion from users. Either the should use a record type, or use `|` everywhere, as in a record contract. * Fix tests after forbidding typed fields without definition * More tests on types vs contracts propagation * Formatting * Apply suggestions from code review Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io> * Update snapshot test output after typo fixup --------- Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
- Loading branch information
Showing
19 changed files
with
408 additions
and
87 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
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.