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?
Comment #2 by k.hara.pg — 2013-05-30T17:43:40Z
Comment #3 by bearophile_hugs — 2013-05-30T17:53:18Z
(In reply to comment #2) > https://github.com/D-Programming-Language/dmd/pull/2103 A quick 1-char patch :-)
Comment #4 by github-bugzilla — 2013-05-30T20:54:05Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/82167d3451694612fdf2d7233f3ce60eb17e2a0a fix Issue 10214 - Incorrect "element-wise assignment is better" warning https://github.com/D-Programming-Language/dmd/commit/1bc83060e2b735c2f1e6bb0cba810829289c1ac1 Merge pull request #2103 from 9rnsr/fix10214 Issue 10214 - Incorrect "element-wise assignment is better" warning
Comment #5 by github-bugzilla — 2013-06-01T11:26:09Z
Commit pushed to 2.063 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/289701cad5bdece3920ff57e97b4b798d76e8d87 Merge pull request #2103 from 9rnsr/fix10214 Issue 10214 - Incorrect "element-wise assignment is better" warning
Comment #6 by github-bugzilla — 2013-06-01T16:02:32Z