Thread overview
[Issue 9074] Can't use range functions with Appender
Apr 24, 2014
Andrej Mitrovic
Apr 24, 2014
Andrej Mitrovic
Jan 02, 2017
Nick Treleaven
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=9074

--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
Different error now:

-----
C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\conv.d(3873): Error: static
assert  "immutable(char) cannot be emplaced from a string."
C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(2522):
instantiated from here: emplaceRef!string
test.d(9):        instantiated from here: put!(Take!(Repeat!string))
-----

Anyone has ideas how to fix this (or if it should be fixed?).

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=9074

monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com

--- Comment #2 from monarchdodra@gmail.com ---
(In reply to Andrej Mitrovic from comment #1)
> Different error now:
> 
> -----
> C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\conv.d(3873): Error: static
> assert  "immutable(char) cannot be emplaced from a string."
> C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(2522):
> instantiated from here: emplaceRef!string
> test.d(9):        instantiated from here: put!(Take!(Repeat!string))
> -----
> 
> Anyone has ideas how to fix this (or if it should be fixed?).

Yeah, use the "actual" std.range.put:

//----
void main()
{
    // Error: casting string to char is deprecated
    // Error: static assert  "Cannot put a dchar into a Appender!(string)"
    Appender!string x;
    put(x, repeat(" ", 4));

    // Error: casting string to dchar is deprecated
    Appender!dstring y;
    put(y, repeat(" ").take(4));
}
//----

This is why you should "never" use put "UFCS-style".
Always "put(a, b)".

Now, when all that is said and done, there's still an internal error, so it needs fixing.

I don't think "Appender" should be able to handle this "natively" though. It should have given a "no matching function" error.

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=9074

--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
Ahh good catch. One of the rare downsides of UFCS.

--
January 02, 2017
https://issues.dlang.org/show_bug.cgi?id=9074

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nick@geany.org
         Resolution|---                         |WORKSFORME

--- Comment #4 from Nick Treleaven <nick@geany.org> ---
Code in comment 2 works now with v2.072.2, closing.

--