Fix allowedReferences corner case

The allowedReferences checked bailed out on the case when the output
referred itself.  Fix this by always adding the output to the allowed set.