Fix '~' operator when acting on variables