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

Type param constraints now respect default cap of the type. #2675

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

Commits on Jan 29, 2024

  1. 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.
    jemc authored and SeanTAllen committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    b0912eb View commit details
    Browse the repository at this point in the history