Thread overview
Passing a sting as 'in char[]' yields "immutable is not callable using argument types ()"
Jun 08, 2016
chmike
Jun 08, 2016
chmike
Jun 08, 2016
NX
June 08, 2016
I have an immutable final class with methods with the following signature

----
import std.typecons;

immutable class Base{
    ...
    @safe pure nothrow
    final Tuple!(int,"value",bool,"hasValue") value(const string name) { return nameImpl(value); }
    @safe pure nothrow
    protected abstract Tuple!(int,"value",bool,"hasValue") valueImpl(const string name);
    ...
}

final immutable class Info: Base{
    ...
    @safe pure nothrow
    static Tuple!(int,"value",bool,"hasValue") value(const string name)
    {
        auto p = name in name2value_; // <-- Error in this line
        return (p) ? Tuple!(int,"value",bool,"hasValue")(*p,true) : Tuple!(int,"value",bool,"hasValue")(int.init,false);
    }
    @safe pure nothrow
    protected override Tuple!(int,"value",bool,"hasValue") valueImpl(const string name) { return value(name); }
    ...
    enum int[string] name2value_ = [ "info_1" : 1, ...];

}
----

When trying to compile this I get the following error

 Error: function Info.value (const(string) name) immutable is not callable using argument types ()

What is the error ? Why is argument types () ?
June 08, 2016
>     final Tuple!(int,"value",bool,"hasValue") value(const string name) { return nameImpl(value); }


Sorry, this is the error. It should have been

   final Tuple!(int,"value",bool,"hasValue") value(const
    string name) { return valueImpl(name); }

June 08, 2016
String is an alias for 'immutable(char)[]'.

I assume you meant const(char)[] instead of 'const string'?

P.S. always use parentheses.