Bug 3893 – opOpAssign and opIndexOpAssign get wrong operator string
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-03-08T01:52:00Z
Last change time
2014-02-15T02:43:55Z
Keywords
spec
Assigned to
nobody
Creator
bugzilla
Comments
Comment #0 by bugzilla — 2010-03-08T01:52:06Z
The specification says:
The expression: a op= b
is rewritten as: a.opOpAssign!("op")(b)
A similar statement is made about opIndexOpAssign. However, what actually happens is that the template parameter is set to "op=", as this program shows:
struct S
{
void opIndexOpAssign(string op)(int x, int i)
{
pragma (msg, op);
}
void opOpAssign(string op)(int x)
{
pragma(msg, op);
}
}
void main()
{
S s;
s[1] += 2;
s += 3;
}
This prints the following on compilation:
+=
+=
Comment #1 by bugzilla — 2010-03-25T07:59:53Z
The documentation has been fixed for opOpAssign, but not for opIndexOpAssign or opSliceOpAssign.
Comment #2 by bugzilla — 2010-03-25T08:01:43Z
Downgrading importance since, apparently, the spec is wrong and not the compiler.
Comment #3 by bugzilla — 2010-08-16T04:46:16Z
The spec was right all along, and the compiler was fixed with DMD 2.047.