fixes circularity check in dependencies

The check for circular loading should depend on a stack of files being
loaded at the moment, rather than the collection of loaded files.

This showed up indirectly in #16468, where a misspelled helper would
incorrectly result in a circularity error message.

References #16468
give a better error message for misspelled helpers

See comment in this patch for the rationale.

References #16468