You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In cases where we are constructing a new object and assigning to that to an explicit type (either as an actual assignment with an explicit type or as an argument passed to a method), and there is a subtyping issue in that assignment which would be solved by surrounding the constructor in a recover ... end, we want to auto-recover the expression and allow that recover ... end to be implicit rather than explicit.
This PR adds checks when assigning a constructor expression or passing one as a parameter to see if it can be auto-recovered, and if so, does not output a subtyping error. E.g. for the following code:
```
actor Main
new create(env: Env) =>
Bar.take_foo(Foo(88))
let bar: Foo iso = Foo(88)
class Foo
new create(v: U8) =>
None
primitive Bar
fun take_foo(foo: Foo iso) =>
None
```
We'd previously get errors on both lines in Main.create(); whereas with this PR they are now accepted.
Fixes#702
Co-authored-by: Sean T Allen <sean@seantallen.com>
Co-authored-by: Jason Carr <jcarr250@protonmail.com>
In cases where we are constructing a new object and assigning to that to an explicit type (either as an actual assignment with an explicit type or as an argument passed to a method), and there is a subtyping issue in that assignment which would be solved by surrounding the constructor in a
recover ... end
, we want to auto-recover the expression and allow thatrecover ... end
to be implicit rather than explicit.Some examples:
This would also solve #415.
The text was updated successfully, but these errors were encountered: