Added exception when comparing non valid types

merging f21de4f