Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 14, 2011 [Issue 6490] New: countUntil will take a non-range for its second argument | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6490 Summary: countUntil will take a non-range for its second argument Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: jmdavisProg@gmx.com --- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-08-14 03:33:15 PDT --- This code compiles: import std.algorithm; void main() { string str = "abc123"; auto i = countUntil!((a, b){return (a >= '0' && a <= '9') || a == '.';}) (str, 0); } It shouldn't. Notice that the second argument to countUntil is 0, which is an int, not a range. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 14, 2011 [Issue 6490] countUntil will take a non-range for its second argument | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=6490 klickverbot <code@klickverbot.at> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |code@klickverbot.at --- Comment #1 from klickverbot <code@klickverbot.at> 2011-08-14 03:43:43 PDT --- Are you sure that this is a bug? The documentation says that it counts until haystack.startsWith!pred(needle) is true, and startsWith is also defined for single element needles. You are right, the usefulness of this behavior is questionable, though. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 14, 2011 [Issue 6490] countUntil will take a non-range for its second argument | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=6490 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-08-14 03:46:35 PDT --- Okay. I misunderstood countUntil. Its signature is sizediff_t countUntil(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) if (is(typeof(startsWith!pred(haystack, needle)))) Of course, I didn't see the template constraint in the documentation, and given the type names, I assumed that needle had to be a range. My mistake. There's no problem with this code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 14, 2011 [Issue 6490] countUntil will take a non-range for its second argument | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | http://d.puremagic.com/issues/show_bug.cgi?id=6490 --- Comment #3 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-08-14 03:47:53 PDT --- The real issue here IMHO is the fact that 0 implicitly converts to a dchar, but that's not going to change anytime soon. The original code that I copied this from was doing that though. I wouldn't normally put a 0 there. In any case, this isn't a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation