[Issue 15236] std.range.chain cannot chain a std.range.repeat string

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Oct 22 12:33:47 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=15236

ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g at gmail.com ---
(In reply to Jack Stouffer from comment #0)
> It thinks that the element
> type for Take!(Repeat!string) is string, so it comes up with
> CommonType!(string, dchar) which is void.

But the ElementType really is string. `repeat` "repeats one value". So if you
pass a string, the elements of the range are that one string again and again.
Then you try to chain a range of dchars (a string) to that range of strings,
which fails as expected.

You have to either join the range of strings from `repeat` into a range of
dchars (std.algorithm.joiner), or turn the single string you want to chain on
into a range (std.range.only).

--


More information about the Digitalmars-d-bugs mailing list