Note that opBinary operators uses op= instead of op : Vector opBinary(string op) (Vector rhs) if(isMathOp(op)) { return Vector(mixin("array.dup[] "~op~"= rhs.array[]")); } Vector opBinary(string op) (T rhs) if(isMathOp(op)) { return Vector(mixin("array.dup[] "~op~"= rhs")); }