Raise appropriate error if referencing undefined name