D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4934 - Cannot compile an overloaded operator returning by ref
Summary: Cannot compile an overloaded operator returning by ref
Status: RESOLVED DUPLICATE of issue 4041
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-24 07:35 UTC by Max Samukha
Modified: 2010-09-25 18:19 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2010-09-24 07:35:00 UTC
struct QString
{
    ref QString opOpAssign(string op : "+")(ref QString s)
    {
        return this;        
    }
}

void main()
{
    QString s;
    s += s; // fails
    s.opOpAssign!("+")(s); // compiles 
}

test.d(12): Error: variable test.QString.op only parameters or foreach declarations can be ref

Compiles if the return type is omitted or the operator is called explicitly.
Comment 1 Shin Fujishiro 2010-09-25 18:19:48 UTC

*** This issue has been marked as a duplicate of issue 4041 ***