On 31.01.21 22:48, Per Nordlöw wrote:
Why isn't

     "Name " ~ name ~ " could not be found"

implicitly convertible to `string`?

If concatenation is guaranteed to allocate a new array, then it should be "strongly pure", and the conversion should work. I'm not sure if it is guaranteed to allocate a new array.

Would

class NameLookupException : Exception
{
     this(scope const(char)[] name) @trusted {
         super("Name " ~ cast(string)name ~ " could not be found");
     }
}

be ok?

Only if you know for sure that you're dealing with a compiler bug here.

As another workaround, you can use std.conv.text:

    import std.conv: text;
    super(text("Name ", name, " could not be found"));

Reply via email to