-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type param constraints now respect default cap of the type.
Prior to this change, any type named in a type constraint would get an implicit cap of `#any` if no explicit cap was named. The exception to this rule is primitives, which will use an implicit cap of `val` in a type constraint (though I'm not sure why you'd ever use a primitive as a type constraint to begin with). In both cases, the default cap declared by the user in the type declaration was being ignored, and this is the only context where that happens, violating the principle of least surprise. I also don't think this deviation is documented anywhere. As a veteran pony programmer, this still surprises and annoys me regularly when I run into it; I commonly make this mistake and have to recompile with an explicit cap that matches my declared default cap. Furthermore, using #any as a type parameter constraint is rarely what you actually want (not constraining the cap at all turns out to not let you do very much), so it doesn't make much sense to be the implicit cap. To illustrate this, there isn't a single example of a type constraint having a final cap of `#any` in the standard library. The lines that have been affected by this change are all cases of using type intersections where only one of the terms was being used to constrain the cap. After this change the default cap declared by the user will be universally respected. This is a breaking change for anyone who is relying on this behaviour.
- Loading branch information
1 parent
d5ab678
commit b0912eb
Showing
5 changed files
with
7 additions
and
17 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