Appender example doesn't work with GDC. GDC bug?

BoraxMan rotflol2 at
Sat Dec 28 03:08:48 UTC 2019

The example for appender located here, does not compile with GDC.

void main()
     import std.array;
     import std.stdio: write, writeln, writef, writefln;
     auto w = appender!string;
     // pre-allocate space for at least 10 elements (this avoids 
costly reallocations)
     assert(w.capacity >= 10);

     w.put('a'); // single elements
     w.put("bc"); // multiple elements

     // use the append syntax
     w ~= 'd';
     w ~= "ef";

     writeln(w[]); // "abcdef"


For the line "Writeln(w[]);" GDC reports "error: no [] operator 
overload for type Appender!string".

It works with DMD.

Time to file  a bug report with GCC-GDC?

More information about the D.gnu mailing list