[Chapel Merge] Keep "called" modules alive for the sake of genera

Branch: refs/heads/main
Revision: 88e15c9
Author: bradcray
Link: Unavailable
Log Message:

Merge pull request #19988 from bradcray/keep-proc-called-modules-alive-for-error

Keep "called" modules alive for the sake of generating errors for them

[developed by @mppf, tested, reviewed, and PR'd by me; reviewed by @lydia-duncan]

Prior to this PR, a module that was "called" but otherwise dead was
dead-code eliminated, causing the compiler error that we'd generate
further along in compilation to refer to dead code. This PR keeps
such called modules alive for the sake of generating a legal error.
It seems that we could also generate the error here, but this
approach has the benefit of emitting all instances of this error
in a single place.

Beyond putting Michael's suggested code change into a PR, I captured
the tests that were filed to highlight this issue from #19932.

Resolves #19932.

Modified Files:
A test/modules/errors/callModLikeProc.chpl

A test/modules/errors/callModLikeProc.good
A test/modules/errors/callModLikeProc2.chpl
A test/modules/errors/callModLikeProc2.good
M compiler/passes/scopeResolve.cpp

Compare: https://github.com/chapel-lang/chapel/compare/af684a0b0a42...88e15c9dd509