-
-
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.
consider instantiation errors in overload resolution as type mismatch
- Loading branch information
Showing
7 changed files
with
118 additions
and
26 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,28 @@ | ||
discard """ | ||
action: "reject" | ||
matrix: "--hints:off -d:testsConciseTypeMismatch" | ||
nimoutFull: true | ||
nimout: ''' | ||
toverloadinstantiation1.nim(28, 6) Error: type mismatch | ||
Expression: foo([1, 2, 3, 4]) | ||
[1] [1, 2, 3, 4]: array[0..3, int] | ||
Expected one of (first mismatch at [position]): | ||
[1] proc foo[I: static int](x: array[double(I), int]) | ||
instantiation error at toverloadinstantiation1.nim(27, 42): | ||
cannot infer the value of the static param 'I' | ||
''' | ||
""" | ||
|
||
proc double(x: int): int = x * 2 | ||
|
||
block: # this not erroring is checked by nimoutFull | ||
proc foo[I: static int](x: array[I, int]) = discard | ||
proc foo[I: static int](x: array[double(I), int]) = discard | ||
foo([1, 2, 3, 4]) | ||
foo[2]([1, 2, 3, 4]) # this picks double overload | ||
|
||
block: | ||
proc foo[I: static int](x: array[double(I), int]) = discard | ||
foo([1, 2, 3, 4]) |
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,29 @@ | ||
discard """ | ||
action: "reject" | ||
matrix: "--hints:off" | ||
nimoutFull: true | ||
nimout: ''' | ||
toverloadinstantiation1_legacy.nim(29, 6) Error: type mismatch: got <array[0..3, int]> | ||
but expected one of: | ||
proc foo[I: static int](x: array[double(I), int]) | ||
first type mismatch at position: 1 | ||
required type for x: array[0..static(pred(double(I))), int] | ||
but expression '[1, 2, 3, 4]' is of type: array[0..3, int] | ||
instantiation error at toverloadinstantiation1_legacy.nim(28, 42): | ||
cannot infer the value of the static param 'I' | ||
expression: foo([1, 2, 3, 4]) | ||
''' | ||
""" | ||
|
||
proc double(x: int): int = x * 2 | ||
|
||
block: # this not erroring is checked by nimoutFull | ||
proc foo[I: static int](x: array[I, int]) = discard | ||
proc foo[I: static int](x: array[double(I), int]) = discard | ||
foo([1, 2, 3, 4]) | ||
foo[2]([1, 2, 3, 4]) # this picks double overload | ||
|
||
block: | ||
proc foo[I: static int](x: array[double(I), int]) = discard | ||
foo([1, 2, 3, 4]) |