Thread overview
[Issue 10214] New: Incorrect "element-wise assignment is better" warning
May 30, 2013
Denis Shelomovskij
May 30, 2013
Andrej Mitrovic
May 31, 2013
Kenji Hara
May 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214

           Summary: Incorrect "element-wise assignment is better" warning
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: verylonglogin.reg@gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-05-30 20:08:27 MSD ---
---
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`)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-05-30 14:13:36 PDT ---
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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, pull


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-30 17:43:40 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2103

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #3 from bearophile_hugs@eml.cc 2013-05-30 17:53:18 PDT ---
(In reply to comment #2)
> https://github.com/D-Programming-Language/dmd/pull/2103

A quick 1-char patch :-)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei@erdani.com
         Resolution|                            |FIXED


--- Comment #4 from github-bugzilla@puremagic.com 2013-05-30 20:54:05 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214



--- Comment #4 from github-bugzilla@puremagic.com 2013-05-30 20:54:05 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei@erdani.com
         Resolution|                            |FIXED


--- Comment #5 from github-bugzilla@puremagic.com 2013-06-01 11:26:09 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10214



--- Comment #6 from github-bugzilla@puremagic.com 2013-06-01 16:02:32 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------