www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11529] New: Unclear error message when rvalue is passed `ref`

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11529

           Summary: Unclear error message when rvalue is passed `ref`
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rscrihf gmail.com



---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 16 2013
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11529


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



12:08:41 PST ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 16 2013