Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Do not allow capability subtyping when checking constraint subtyping. #1816
The compiler currently allows contravariant constraint for type arguments. When
In other words, it allows the following, where
This is however unsound, as shown in the example below. Bar's
As a result, this can be used to duplicate an iso reference, as shown in
trait Foo fun alias[X: Any iso](x: X!) : X^ class Bar is Foo fun alias[X: Any tag](x: X!) : X^ => x class Baz actor Main new create(env: Env) => let foo : Foo = Bar let x : Baz iso = Baz let x' : Baz iso = foo.alias[Baz iso](x)
Instead, when checking constraint subtyping, the compiler should not allow
Playground link with a more complete example: https://is.gd/vYNExP
Yeah, I think all the type system bugs are definitely important enough to warrant a release.
The only reason we may want to hold back on releasing them would be if we wanted to fit more than one of these bugfixes in before the release. So I'd just suggest we check in with @plietar to see if he's planning to file any more bugfixes in the near future that might want to make us wait for those for the next release.
I've added a test for this PR, it should be good to merge now.
We should probably fix #1798 and make a release with the two, although I'm not sure how hard it is to fix. I've had a look at it and I have a few clues of what's going on, but I am not (yet) familiar enough with the typechecker implementation to fix it myself. I'll add a few notes over there.
The other issues are about valid but fairly exotic programs which the compiler refuses/crashes on. Since they don't cause any unsoundness they are less important to fix and release IMO. I don't have anything else in the queue atm.