cannot implicitly convert char[] to string

Timon Gehr via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 15 05:05:04 PDT 2015


On 08/15/2015 01:54 PM, Timon Gehr wrote:
> On 08/15/2015 01:25 PM, vladde wrote:
>> I made a PR to phobos where I modified `std.format.format`.
>> https://github.com/D-Programming-Language/phobos/pull/3528
>>
>> However the auto builder fails, with the error message:
>>> runnable/test23.d(1219): Error: cannot implicitly convert expression
>>> (format("s = %s", s)) of type char[] to string
>>
>> The line which fails is `p = std.string.format("s = %s", s);`
>>
>> I don't understand why I can't convert a char[] to string.
>
> Get rid of the 'in' in format's signature.

Oh, I see, this is by design (which I don't like, but OK.)
The reason the conversion does not go through is that format is not 
marked as pure.


More information about the Digitalmars-d-learn mailing list