Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7584 from ntrel/count-args
Fix Issue 16165 - Show expected number of function arguments on mismatch
- Loading branch information
Showing
9 changed files
with
137 additions
and
39 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,18 @@ | ||
void f(int x, Object y); | ||
|
||
void g() | ||
{ | ||
Object o; | ||
f(o, o, 404); | ||
f(5, 6, 404); | ||
} | ||
|
||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/bug16165.d(6): Error: function `bug16165.f(int x, Object y)` is not callable using argument types `(Object, Object, int)` | ||
fail_compilation/bug16165.d(6): cannot pass argument `o` of type `object.Object` to parameter `int x` | ||
fail_compilation/bug16165.d(7): Error: function `bug16165.f(int x, Object y)` is not callable using argument types `(int, int, int)` | ||
fail_compilation/bug16165.d(7): cannot pass argument `6` of type `int` to parameter `Object y` | ||
--- | ||
*/ |
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 |
---|---|---|
@@ -1,15 +1,56 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail332.d(14): Error: function `fail332.foo(int _param_0, ...)` is not callable using argument types `()` | ||
fail_compilation/fail332.d(22): Error: function `fail332.foo(int _param_0, ...)` is not callable using argument types `()` | ||
fail_compilation/fail332.d(22): missing argument for parameter #1: `int _param_0` | ||
fail_compilation/fail332.d(23): Error: function `fail332.foo(int _param_0, ...)` is not callable using argument types `(typeof(null))` | ||
fail_compilation/fail332.d(23): cannot pass argument `null` of type `typeof(null)` to parameter `int _param_0` | ||
fail_compilation/fail332.d(25): Error: function `fail332.baz(int[] _param_0...)` is not callable using argument types `(string)` | ||
fail_compilation/fail332.d(25): cannot pass argument `""` of type `string` to parameter `int[] _param_0...` | ||
fail_compilation/fail332.d(26): Error: function `fail332.baz(int[] _param_0...)` is not callable using argument types `(int, typeof(null))` | ||
fail_compilation/fail332.d(26): cannot pass argument `null` of type `typeof(null)` to parameter `int[] _param_0...` | ||
--- | ||
*/ | ||
|
||
import core.vararg; | ||
|
||
void foo(int, ...) {} | ||
void baz(int[]...) {} | ||
|
||
void bar() | ||
void test() | ||
{ | ||
foo(); | ||
foo(null); | ||
|
||
baz(""); | ||
baz(3, null); | ||
} | ||
|
||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail332.d(50): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `()` | ||
fail_compilation/fail332.d(50): missing argument for parameter #1: `Object` | ||
fail_compilation/fail332.d(51): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(int)` | ||
fail_compilation/fail332.d(51): cannot pass argument `4` of type `int` to parameter `Object` | ||
fail_compilation/fail332.d(52): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null))` | ||
fail_compilation/fail332.d(52): expected 2 variadic argument(s), not 0 | ||
fail_compilation/fail332.d(53): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null), int)` | ||
fail_compilation/fail332.d(53): expected 2 variadic argument(s), not 1 | ||
fail_compilation/fail332.d(54): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null), int, string)` | ||
fail_compilation/fail332.d(54): cannot pass argument `""` of type `string` to parameter `int[2]...` | ||
fail_compilation/fail332.d(55): Error: function `fail332.bar(Object, int[2]...)` is not callable using argument types `(typeof(null), int, int, int)` | ||
fail_compilation/fail332.d(55): expected 2 variadic argument(s), not 3 | ||
--- | ||
*/ | ||
void bar(Object, int[2]...); | ||
|
||
void test2() | ||
{ | ||
bar(); | ||
bar(4); | ||
bar(null); | ||
bar(null, 2); | ||
bar(null, 2, ""); | ||
bar(null, 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
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