Summary: Calling std.string.split with static array for
                    separator fails to compile
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Phobos

--- Comment #0 from 2010-06-14 23:52:59 PDT ---
Using D 2.047, get a template error at compilation from std.algorithm when
calling split with a static array as the separator.

The following code:

  module main;
  import std.string;
  void main() {
      char[3] foo = "t n";
      string[] sa = split("split me now", foo);

fails with:

...phobos\std\algorithm.d(796): Error: template std.range.retro(R) if
(isBidirectionalRange!(R)) does not match any function template declaration
...phobos\std\algorithm.d(796): Error: template std.range.retro(R) if
(isBidirectionalRange!(R)) cannot deduce template function from argument types

This means the character sets provided in std.string cannot be used, i.e.

  split("some string", whitespace)

will fail.  Using an immutable array (as the char sets are) surfaces an
additional compiler error:

...phobos\std\algorithm.d(804): Error: slice this._separator[] is not mutable

Think there are actually two issues here, though fixing one likely fixes the
1. It doesn't work (see above).
2. Errors reported are rather difficult to track back to cause - there is no
indication of what originally triggered the algorithm/range code.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to