www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2788] New: return val not passable via ref const in other method

reply d-bugmail puremagic.com writes:

           Summary: return val not passable via ref const in other method
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: spam extrawurst.org

This used work perfectly fine, why not anymore ? (since 2.027)

int getVar()
        return 2;

void foo(ref const int _p)

void main()

Error: function main.foo (ref const const(int) _p) does not match parameter
types (int)
Error: getVar() is not an lvalue

Apr 02 2009
parent d-bugmail puremagic.com writes:

Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
                 CC|                            |mrmocool gmx.de
           Platform|x86                         |All
         OS/Version|Windows                     |All

--- Comment #1 from Trass3r <mrmocool gmx.de> 2011-03-01 06:28:43 PST ---
ref const doesn't make any sense with basic types.

But it makes sense for struct and static array temporaries.

The weird thing is struct literals count as lvalues in D2, so this works:

struct A {}
void foo(ref A a) {}
void main()

while calling the following doesn't:
static A bar()
    return A();


Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2011