-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bca3cc1
commit 06537a0
Showing
3 changed files
with
99 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
trait Eq[T] { | ||
fn eq(other: T) | ||
} | ||
|
||
class Thing {} | ||
|
||
impl Eq[uni Thing] for Thing { | ||
fn eq(other: uni Thing) {} | ||
} | ||
|
||
impl Eq[uni Int] for Int { | ||
fn eq(other: uni Int) {} | ||
} | ||
|
||
fn foo[F: Eq[F]](value: F) {} | ||
|
||
fn bar { | ||
# This isn't valid because `Thing` implements `Eq[uni Thing]`. Passing | ||
# `Thing` `F: Eq[F]` results in `F: Eq[Thing]`. If we allowed this, we'd be | ||
# able to pass a `Thing` to `Thing.eq` which violates the `uni` constraint of | ||
# the `other` argument. | ||
foo(Thing {}) | ||
|
||
# This _is_ valid because Int is a value type. | ||
foo(42) | ||
} | ||
|
||
# uni_with_owned.inko:14:7 error(invalid-type): expected a value of type 'F', found 'Thing' |
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