-
-
Notifications
You must be signed in to change notification settings - Fork 676
Fix Issue 15613, 11529: Show parameter mismatch and rvalue/lvalue ref message #7554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
48c6b49
ff99241
c48e834
66a74ee
7421577
2ef0b7d
15b1b50
a693e69
0948ed9
04f41db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/bug15613.d(16): Error: function `bug15613.f(int...)` is not callable using argument types `(typeof(null))` | ||
| fail_compilation/bug15613.d(16): cannot pass argument `null` of type `typeof(null)` to parameter `int...` | ||
| fail_compilation/bug15613.d(17): Error: function `bug15613.g(Object, ...)` is not callable using argument types `(int)` | ||
| fail_compilation/bug15613.d(17): cannot pass argument `8` of type `int` to parameter `Object` | ||
| --- | ||
| */ | ||
|
|
||
| void f(int...); | ||
| void g(Object, ...); | ||
|
|
||
| void main() | ||
| { | ||
| f(null); | ||
| g(8); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,3 +58,54 @@ void test3() | |
| S[1] sa = cast(S[1])ta; | ||
| auto t2 = cast(tem!().S[])sa; | ||
| } | ||
|
|
||
| /* | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/bug9631.d(79): Error: function `bug9631.arg.f(int i, S s)` is not callable using argument types `(int, S)` | ||
| fail_compilation/bug9631.d(79): cannot pass argument `y` of type `bug9631.tem!().S` to parameter `bug9631.S s` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that line 66 calls it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The point is to disambiguate between S and tem!().S. You're right that the module name isn't needed, but it makes it clear that the compiler has fully qualified the type. In the first line, there's no qualification so that it's easier to read the function parameters. Given this, if I remove the module name, it might not be so clear.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| fail_compilation/bug9631.d(80): Error: function literal `__lambda2(S s)` is not callable using argument types `(S)` | ||
| fail_compilation/bug9631.d(80): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S s` | ||
| fail_compilation/bug9631.d(86): Error: constructor `bug9631.arg.A.this(S _param_0)` is not callable using argument types `(S)` | ||
| fail_compilation/bug9631.d(86): cannot pass argument `S(0)` of type `bug9631.tem!().S` to parameter `bug9631.S _param_0` | ||
| --- | ||
| */ | ||
| void arg() | ||
| { | ||
| S x; | ||
| tem!().S y; | ||
|
|
||
| void f(int i, S s); | ||
| f(4, y); | ||
| (tem!().S s){}(x); | ||
|
|
||
| struct A | ||
| { | ||
| this(S){} | ||
| } | ||
| A(tem!().S()); | ||
| } | ||
|
|
||
| /* | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/bug9631.d(106): Error: function `bug9631.targ.ft!().ft(S _param_0)` is not callable using argument types `(S)` | ||
| fail_compilation/bug9631.d(106): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S _param_0` | ||
| fail_compilation/bug9631.d(107): Error: template `bug9631.targ.ft` cannot deduce function from argument types `!()(S)`, candidates are: | ||
| fail_compilation/bug9631.d(105): `bug9631.targ.ft()(tem!().S)` | ||
| fail_compilation/bug9631.d(109): Error: template `bug9631.targ.ft2` cannot deduce function from argument types `!()(S, int)`, candidates are: | ||
| fail_compilation/bug9631.d(108): `bug9631.targ.ft2(T)(S, T)` | ||
| --- | ||
| */ | ||
| void targ() | ||
| { | ||
| S x; | ||
| tem!().S y; | ||
|
|
||
| void ft()(tem!().S){} | ||
| ft!()(x); | ||
| ft(x); | ||
| void ft2(T)(S, T){} | ||
| ft2(y, 1); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest special casing
nullso it reads: "cannot passnullto parameterint...". "nullof typetypeof(null)" is quite an odd thing to say. I'll still approve this PR without this change, as this PR is a huge improvement over the current implementation, so it's your call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, maybe. This is a general issue though, e.g.
int x = null;gives: