Bug 13257 – [REG2.067a] Deprecation message when using std.getopt with string[] parameter

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-04T22:19:00Z
Last change time
2014-08-18T20:50:00Z
Keywords
pull
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2014-08-04T22:19:32Z
/////////// test.d /////////// import std.getopt; void main(string[] args) { string[] foo; getopt(args, "foo", &foo); } ////////////////////////////// This results in a deprecation message deep in Phobos: C:\...\std\algorithm.d(483): Deprecation: function std.algorithm.splitter!(string, string).splitter.Result.back is deprecated - splitter!(Range, Range) cannot be iterated backwards (due to separator overlap). C:\...\std\algorithm.d(488): Deprecation: function std.algorithm.splitter!(string, string).splitter.Result.popBack is deprecated - splitter!(Range, Range) cannot be iterated backwards (due to separator overlap). Introduced in https://github.com/D-Programming-Language/phobos/pull/1475
Comment #1 by monarchdodra — 2014-08-04T23:01:55Z
Hum... seems like a limitation of *how* deprecation works. In particular, how "is(typeof(...))" interacts with it. It's kind of like: - "Do you have back?" - "Yes." - "I'd like to call back." - "NO! YOU CAN'T! IT'S DEPRECATED!" Case in point, reduced: //---- import std.algorithm; void main(string[] args) { int[] a, b; splitter(a, b); //No warning here splitter(a, b).map!"a"(); //WARNING HERE } //---- Here, 'map' "thinks" (correctly or not) that it splitter is bidirectional, so generates a 'back', which ends up calling a deprecated 'back'. What's "funny" is that this only triggers in "deprecated features as warnings". If you compile with "deprecated features as errors", then the problem actually goes away. That said, you actually generate a different program. Which is actually a bit disturbing, IMO.
Comment #2 by monarchdodra — 2014-08-04T23:02:46Z
(In reply to monarchdodra from comment #1) > Hum... seems like a limitation of *how* deprecation works. I'm not sure how to deal with this specific situation. What do we do?
Comment #3 by dlang-bugzilla — 2014-08-04T23:03:59Z
(In reply to monarchdodra from comment #1) > What's "funny" is that this only triggers in "deprecated features as > warnings". If you compile with "deprecated features as errors", then the > problem actually goes away. OK, that explains the other thing. *stops DustMite reduction*
Comment #4 by dlang-bugzilla — 2014-08-04T23:06:38Z
I don't know if this is feasible as I guess it'd have to be replicated across many other ranges, but one possibility would be to make MapResult.back a template function. Then, it will only be instantiated when actually used by the map consumer.
Comment #5 by k.hara.pg — 2014-08-07T12:41:51Z
This is git-head only regression, and does not occur with 2.066-rc1.
Comment #6 by hsteoh — 2014-08-08T17:02:53Z
This regression affects rdmd.d in the tools repo.
Comment #7 by hsteoh — 2014-08-08T17:17:08Z
Here's a minimal test case (reduced from rdmd.d (dustmite + manual + 2nd dustmite + 2nd manual)): ----- import std.algorithm; void main() { string val; foreach (elem; val.splitter(val).map!(a => a)) {} } ----- Compile command: dmd rdmd.d Compiler output: ----- /usr/src/d/phobos/std/algorithm.d(483): Deprecation: function std.algorithm.splitter!(string, string).splitter.Result.back is deprecated - splitter!(Range, Range) cannot be iterated backwards (due to separator overlap). /usr/src/d/phobos/std/algorithm.d(488): Deprecation: function std.algorithm.splitter!(string, string).splitter.Result.popBack is deprecated - splitter!(Range, Range) cannot be iterated backwards (due to separator overlap). -----
Comment #8 by hsteoh — 2014-08-08T17:19:45Z
Even more reduced: ----- import std.algorithm; void main() { auto x = "".splitter("").map!(a => a); } -----
Comment #9 by monarchdodra — 2014-08-08T20:07:14Z
(In reply to hsteoh from comment #8) > Even more reduced: > ----- > import std.algorithm; > void main() > { > auto x = "".splitter("").map!(a => a); > } > ----- Hum... I had already reduced it to that: https://issues.dlang.org/show_bug.cgi?id=13257#c1
Comment #10 by hsteoh — 2014-08-08T20:27:30Z
Ah, right. Missed it while glancing over the comments. :-(
Comment #11 by public — 2014-08-09T10:42:47Z
Feels like we may need is(symbol == deprecated) expression >_<
Comment #12 by public — 2014-08-09T10:43:34Z
Another option is to special case splitter in map and make this deprecation cycle as short as possible
Comment #13 by hsteoh — 2014-08-10T22:51:24Z
Not sure this is the right solution, but here goes (based on Vladimir's idea): https://github.com/D-Programming-Language/phobos/pull/2415
Comment #14 by github-bugzilla — 2014-08-18T20:07:06Z
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/676290c36db208d13b93d1a45a87fefee26c1eb9 Merge pull request #2415 from quickfur/issue13257 Workaround deprecation of splitter.{back,popBack} in std.algorithm.map.