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.
Comment #3 by nick — 2017-12-30T17:31:52Z
Comment #4 by nick — 2017-12-30T17:38:22Z
*** Issue 12019 has been marked as a duplicate of this issue. ***
Comment #5 by nick — 2017-12-30T17:38:45Z
*** Issue 13655 has been marked as a duplicate of this issue. ***
Comment #6 by github-bugzilla — 2018-01-26T06:36:45Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/ff99241a38068e85af6e2625e10ce78b2201de57 Fix Issue 11529 - Unclear error message when rvalue is passed as `ref' Also hide separate parameter type when already shown. https://github.com/dlang/dmd/commit/fcc69c18c439009508e1e57ea1f91970ffdf9b2b Merge pull request #7554 from ntrel/qual-arg Fix Issue 15613, 11529: Show parameter mismatch and rvalue/lvalue ref message merged-on-behalf-of: Sebastian Wilzbach <[email protected]>
Comment #7 by dlang-bot — 2021-04-02T05:45:18Z
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