-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #6407 SomeFloat and SomeInteger types fails to differentiate in a…
… generic call from other generic
- Loading branch information
Showing
10 changed files
with
129 additions
and
15 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
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,10 @@ | ||
|
||
proc foo[T](x: T):int = 1 | ||
|
||
proc foo[T: tuple](x: T):int = 2 | ||
|
||
doAssert foo((1, 2, 3)) == 2 | ||
|
||
type Obj = object | ||
proc foo(x: object):int = 3 | ||
doAssert foo(Obj()) == 3 |
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,14 @@ | ||
discard """ | ||
disabled: true | ||
""" | ||
|
||
type | ||
A = ref object of RootObj | ||
B = ref object of A | ||
C = ref object of B | ||
|
||
proc foo[T: A](a: T):int = 1 | ||
proc foo[T: B](b: T):int = 2 | ||
|
||
var c = C() | ||
doAssert foo(c) == 2 |
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,13 @@ | ||
discard """ | ||
disabled: true | ||
""" | ||
|
||
type | ||
Image[T: int32|int64] = object | ||
data: seq[T] | ||
|
||
proc newImage[T](w, h: int): ref Image[T] = | ||
new(result) | ||
result.data = newSeq[T](w * h) | ||
|
||
var i = newImage[string](320, 200) |
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,12 @@ | ||
discard """ | ||
action: compile | ||
""" | ||
|
||
proc foo[T6407: SomeFloat](y: T6407):int = 0 | ||
|
||
proc foo[T6407: SomeInteger](y: T6407):int = 1 | ||
|
||
proc boo[T6407](x: T6407):int = | ||
foo[T6407](x) | ||
|
||
doAssert boo(1) == 1 |
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,10 @@ | ||
discard """ | ||
action: compile | ||
""" | ||
|
||
proc sort[T: uint8|char|byte](c: T) = discard | ||
proc sort[T: bool](c: T) = discard | ||
|
||
proc sorted[T](c: T): T = sort[T](c) | ||
|
||
doAssert sorted(true) == false |