Fix bug #65322: compile time errors won't trigger auto loading

Also fixes duplicate bugs #54054 and #42098.

Furthermore this fixes incorrect error messages thrown from code
running inside an error handler when a compilation is in progress.
The error file and line are now correctly associated with the
file/line of the executor, rather than the compiler.