Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make type checking return types sound
When a method returns a type parameter or a type containing a type parameter, without an explicit ownership, we no longer consider references to the type parameter to be compatible with it. This means code such as this is no longer valid: class Box[V] { let @value: V fn foo -> V { @value } } Without these changes the above code is unsound, as for `Box[User]` the return type of `Box.foo` is inferred as `User`, when in reality a `ref User` is returned. Changelog: fixed
- Loading branch information
1 parent
7138301
commit 6f2341e
Showing
4 changed files
with
131 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Box[V] { | ||
let @value: V | ||
|
||
fn foo -> V { | ||
@value | ||
} | ||
|
||
fn move bar -> V { | ||
@value | ||
} | ||
} | ||
|
||
impl Box if V: mut { | ||
fn mut baz -> V { | ||
@value | ||
} | ||
} | ||
|
||
# return_when_any_is_expected.inko:5:5 error(invalid-type): expected a value of type 'V', found 'ref V' | ||
# return_when_any_is_expected.inko:15:5 error(invalid-type): expected a value of type 'V: mut', found 'mut V: mut' |
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