Bug 12019 – Better error message for refused ref function argument
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-28T08:50:22Z
Last change time
2017-12-30T17:38:22Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2014-01-28T08:50:22Z
This is wrong code:
void foo(ref int[1] b) {}
void main() {
ubyte[4] a;
foo(cast(int[1])a);
}
dmd 2.065beta gives correctly an error message:
test.d(4): Error: function test.foo (ref int[1] b) is not callable using argument types (int[1])
But I'd like the error message to explain why it can't compile, that it can't be accepted by reference. Something like:
test.d(4): Error: function test.foo (ref int[1] b) is not callable using argument types cast(int[1]) because it is not an lvalue
Comment #1 by nick — 2017-12-30T17:38:22Z
*** This issue has been marked as a duplicate of issue 11529 ***