fix Issue 9741 - undefined identifier with User Defined Attribute

Also fixes incorrect 'undefined identifier' error in `fail_compilation/ice11919.d`.