[Issue 14841] New: Don't warn on myArray.sort when it makes no difference

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jul 27 19:37:12 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14841

          Issue ID: 14841
           Summary: Don't warn on myArray.sort when it makes no difference
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: markisaa at umich.edu

Just upgraded the compiler at work and found:
"foo.d(6): Warning: use std.algorithm.sort instead of .sort property"

to be the most jarring change in the compiler so far. Namely, I've written code
of the form:
import std.algorithm;
auto x = [1, 2, 3, 5, 4];
x.sort.writeln;

which should behave the same regardless of whether or not std.algorithm.sort is
used or the .sort property is used. The deprecation statement in the changelog
for the .sort property removal basically just says that it belongs in Phobos
instead. Why then do we nag users about this when the code is functionally
correct and robust even if/when we remove the .sort property from the language?

Proposed enhancement: don't warn if std.algorithm.sort has been imported (aka,
don't warn if the removal of the .sort property would be transparent).

--


More information about the Digitalmars-d-bugs mailing list