www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - opAssign is not callable because it is annotated with disable with

Hello,

I am currently trying to improve the TOML library of: 
https://github.com/iccodegr/toml.d

I get a really weird error:

Error: function main.TOMLValue.opAssign is not callable because 
it is annotated with  disable

I have tested this with dmd 2.071.1 and 2.068.0.

Here is the code to reproduce it:

import std.datetime: SysTime, DateTime;
import std.stdio;
import std.conv;
import std.exception;

enum TOMLType {
     String,
     Integer,
     Float,
     Boolean,
     DateTime,
     Array,
     Group
}

// Changing this to DateTime makes it compile
alias TOMLDateTimeType = SysTime;

class TOMLException: Exception {
     this(string msg, string file="parser", size_t line=111) {
         super(msg, file, line);
     }
}

alias enforceTOML = enforceEx!(TOMLException);


struct TOMLValue {

     union Store {
         string stringv;
         long intv;
         float floatv;
         bool boolv;
         TOMLDateTimeType datetimev;
         TOMLValue[] arrayv;
         TOMLValue[string] keygroups;
     }

     private {
         Store _store;
         TOMLType _type;
     }

     // Does not work with this either

     //private void assign(T)(T val, string key) {
     //    static if ( is(T: TOMLValue) )
     //        _store.keygroups[key] = val;
     //    else
     //        _store.keygroups[key] = TOMLValue(val);
     //}

     TOMLValue opIndexAssign(TOMLValue  v, string key) {
         enforceTOML(_type==TOMLType.Group);
         _store.keygroups[key] = v;
         return v;
     }


}


void main() {
	TOMLType a = TOMLType.String;
	writeln(a.to!string);


}

It doesn't really make any sense to me. Could anyone explain to 
me what's going on?

Thank you for your time
Aug 02 2016