Bug 14841 – Don't warn on myArray.sort when it makes no difference
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-28T02:37:00Z
Last change time
2016-03-25T21:28:32Z
Assigned to
nobody
Creator
markisaa
Comments
Comment #0 by markisaa — 2015-07-28T02:37:12Z
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).
Comment #1 by dlang-bugzilla — 2015-09-01T06:07:52Z
FWIW, you can work around the warning by writing `x.sort().writeln;` (add a pair of parens).
Comment #2 by dmitry.olsh — 2015-09-01T06:31:05Z
> 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?
Because built-in sort is broken junk? There is good reason to get rid of that built-in and nagging message makes sure nobody would use that thing by accident.
Comment #3 by markisaa — 2016-03-25T21:28:32Z
This seems to no longer be an issue in the new beta version of dmd... it looks like the repro I had listed no longer repros.