Detecting ambiguous references