Fix an assertion failure when the referenced declaration is a variable