[Issue 18472] [Reg 2.078] betterC: cannot use format at compile time.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 20 17:16:03 UTC 2018


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

Martin Nowak <code at dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code at dawg.eu
            Summary|betterC: cannot use format  |[Reg 2.078] betterC: cannot
                   |at compile time.            |use format at compile time.

--- Comment #2 from Martin Nowak <code at dawg.eu> ---
cat > bug.d << CODE
import std.format;
import std.stdio;
void main()
{
    enum s = "%1$s,%2$s".format("foo","bar");
    writeln(s);
}
CODE
dmd -c -betterC bug.d
----
/home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/range/primitives.d(405):
Error: static assert  "Cannot put a const(char)[] into a Appender!string."
/home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(1172):  
     instantiated from here: put!(Appender!string, const(char)[])
/home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(473):   
    instantiated from here: writeUpToNextSpec!(Appender!string)
/home/dawg/dlang/dmd-2.078.0/linux/bin64/../../src/phobos/std/format.d(5831):  
     instantiated from here: formattedWrite!(Appender!string, char, string,
string)
/home/dawg/Code/D/bug.d(5):        instantiated from here: format!(char,
string, string)
----

Confirmed that this stopped to work with 2.078.0, the error looks rather weird,
as betterC shouldn't change types.

Also indeed with 2.079.0-beta.1 the error message is now about using TypeInfo.
----
/home/dawg/dlang/dmd-2.079.0-beta.1/linux/bin64/../../src/phobos/std/array.d(2889):
Error: TypeInfo cannot be used with -betterC
----

The test case compiles fine with 2.077.1.

--


More information about the Digitalmars-d-bugs mailing list