digitalmars.D.bugs - [Issue 10543] New: std.algorithm.map incorrectly uses source range length for narrow strings
- d-bugmail puremagic.com (28/28) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (8/9) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (10/10) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (7/8) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (11/11) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (18/20) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (15/16) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (9/19) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (12/12) Jul 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (14/14) Jul 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
- d-bugmail puremagic.com (10/10) Jul 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10543
http://d.puremagic.com/issues/show_bug.cgi?id=10543 Summary: std.algorithm.map incorrectly uses source range length for narrow strings Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: peter.alexander.au gmail.com 09:30:32 PDT --- void main() { import std.algorithm; import std.stdio; string s = "こんにちは世界"; auto m = s.map!(a => 1); writeln(m, ", ", m.length); } Gives: [1, 1, 1, 1, 1, 1, 1], 21 Clearly the reported length (21) is wrong, it should be 7. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 09:31:54 PDT ---Clearly the reported length (21) is wrong, it should be 7.Scratch that. length shouldn't be available at all for narrow strings as it is unobtainable in constant time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc Where's the bug here? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 10:43:22 PDT ---Where's the bug here?It says the length of [1, 1, 1, 1, 1, 1, 1] is 21. It isn't. It's 7. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 9999 <mailnew4ster gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mailnew4ster gmail.com 21 is the number of UTF-8 code units. Using dstring produces 7. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 10:54:42 PDT ---21 is the number of UTF-8 code units. Using dstring produces 7.I am not requesting the length of the string, I am requesting the length of the map over the string. As ranges, strings are ranges of code points, not code units, so the number of elements in the *map* (confirmed by the output) is seven, i.e. that is the number of times you can safely call popFront on the map. I'm struggling to understand the confusion. m is a range of seven integers m.length is 21 walkLength(m) is also 21 This is completely broken. I fully understand that narrow strings use length to report code units, not code points, but m is not a string, so that distinction does not apply. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra gmail.comI'm struggling to understand the confusion.The problem is perfectly clear. Are you already correcting this? If not, I'll take care of it. I remember having seen this in one of my first pulls correcting map, but got confused about the fact there is an *explicit* test to do things wrong... Time to correct it for good I guess. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 13:15:10 PDT ---I'm not fixing it right now, go ahead. I only noticed it when I looked at the source. No idea why it's explicitly coded to be wrong... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------I'm struggling to understand the confusion.The problem is perfectly clear. Are you already correcting this? If not, I'll take care of it. I remember having seen this in one of my first pulls correcting map, but got confused about the fact there is an *explicit* test to do things wrong... Time to correct it for good I guess.
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid Status|NEW |ASSIGNED AssignedTo|nobody puremagic.com |monarchdodra gmail.com https://github.com/D-Programming-Language/phobos/pull/1389 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/0a710876007bf8509d4f62453311e0bb6adbc7ca Fix Issue 10543 - std.algorithm.map incorrectly uses source range length for narrow strings Strange, because there was an explicit override for strings to forward length. In any case, this is now fixed. https://github.com/D-Programming-Language/phobos/commit/201edf4c8055ca0ac0079b9a8b711b68668c7974 Fix Issue 10543 - std.algorithm.map incorrectly uses source range length... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 06 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10543 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Status|ASSIGNED |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 06 2013