Bug 10214 – Incorrect "element-wise assignment is better" warning
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-30T09:08:00Z
Last change time
2013-06-01T16:02:32Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2013-05-30T09:08:27Z
---
void main()
{
bool[1] arr;
arr = 0; // line 4
}
---
dmd output:
---
main.d(4): Warning: explicit element-wise assignment (arr)[] = (0)[] is better than arr = 0
---
(it should be no slice after `0`)
Comment #1 by andrej.mitrovich — 2013-05-30T14:13:36Z
The compiler code:
-----
if (e2->op == TOKslice || t2->implicitConvTo(t1->nextOf()))
warning("explicit element-wise assignment (%s)[] = %s is better than %s = %s",
e1str, e2str, e1str, e2str);
else
warning("explicit element-wise assignment (%s)[] = (%s)[] is better than %s = %s",
e1str, e2str, e1str, e2str);
-----
It almost seems like the two warnings should be swapped around?