Bug 11529 – Unclear error message when rvalue is passed as `ref'
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-16T10:17:52Z
Last change time
2021-04-02T05:45:18Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Roy Crihfield
Comments
Comment #0 by rscrihf — 2013-11-16T10:17:52Z
Compiling this:
struct S {}
void f(ref S s) {}
void main()
{
f(S());
}
Gives an error without a clear explanation:
Error: function f730.f (ref S s) is not callable using argument types (S)
This should at the very least give an indication that the struct passed is a temporary. Especially for those unfamiliar with the language, there's no obvious indication of a type mismatch.
The same issue applies to `const ref' and `in ref' parameters.
Comment #1 by andrej.mitrovich — 2013-11-16T12:08:41Z
2.062:
test.d(6): Error: function test.f (ref S s) is not callable using argument types (S)
test.d(6): Error: S() is not an lvalue
2.063:
test.d(6): Error: function test.f (ref S s) is not callable using argument types (S)
Caused by https://github.com/D-Programming-Language/dmd/pull/1842 which I objected to.
Comment #2 by dfj1esp02 — 2015-09-21T09:01:07Z
It's also a problem for functions with many parameters to determine, which parameter was passed with a wrong argument.
dlang/dmd pull request #12339 "[dmd-cxx] Backport fixes and trivial features from upstream dmd" was merged into dmd-cxx:
- 8f461425adb1e69bf02abf88b4e73585316b05af by Nick Treleaven:
[dmd-cxx] Fix Issue 15613, 11529: Show parameter mismatch and rvalue/lvalue ref message
https://github.com/dlang/dmd/pull/12339