Passing a sting as 'in char[]' yields "immutable is not callable using argument types ()"

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 8 08:06:29 PDT 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 () ?


More information about the Digitalmars-d-learn mailing list