I have this struct:

immutable struct Configuration {
    string title;
    string baseurl;
    string url;
    string email;
    string author;
    string parser;
    string target;
    string urlFormat;
    string urlFormatCmd;

    short port;

    string[] ignore;
    string[] extensions;

    @property string toString()
    {
auto urlF = (urlFormatCmd ? "url_format_cmd: " ~ urlFormatCmd : "") ~ "\n";
        return
        "title: "        ~ title ~ "\n" ~
        "baseurl: "      ~ baseurl ~ "\n" ~
        "url: "          ~ url ~ "\n" ~
        "email: "        ~ email ~ "\n" ~
        "author: "       ~ author ~ "\n" ~
        "parser: "       ~ parser ~ "\n" ~
        "target: "       ~ target ~ "\n" ~
        "url_format: "   ~ urlFormat ~ "\n" ~
        "ignore: "       ~ to!string(ignore)[1 .. $ - 1] ~ "\n" ~
"extensions: " ~ to!string(extensions)[1 .. $ - 1] ~ "\n" ~
        urlF;
    }
}

and this function:

void show_config()
{
    writef("%s", parse_config(
exists("config.sdl") ? "config.sdl" : "").toString);
}


Whenever I compile with ldc2 I get no errors, while with dmd I get:

source/configuration.d(105,27): Error: immutable method configuration.Configuration.toString is not callable using a mutable object


What is the problem?

Reply via email to