D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10428 - Assignment operator returns by value (not by ref like you'd expect)
Summary: Assignment operator returns by value (not by ref like you'd expect)
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-20 14:02 UTC by Tommi
Modified: 2021-05-11 09:23 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 Tommi 2013-06-20 14:02:16 UTC
Assignment operators should return by ref, not by value.

void edit(ref int) { }

void main()
{
    int n;
    edit(n += 4); // OK
    edit(n = 4); // [1]
}

---
1) Error: function main.edit (ref int _param_0) is not callable using argument types (int)
Comment 1 RazvanN 2021-05-11 09:23:33 UTC
This code compiles succesfully today. Closing as w4m.