Merge pull request #18622 from lydia-duncan/onlyExceptRespectPrivate
Fix bug with allowing limitation clauses to mention symbols behind private uses/imports
[reviewed by @mppf]
Prior to this change, validating except/only lists or import unqualified access
lists was not respecting the privacy of use and import statements, so we would
not error when validating those lists if the symbol could be found down a
private use or import chain. Such symbols shouldn't be reference-able in other
parts of the code either, but the error should be caught sooner.
This change adjusts that validation to avoid looking in such private uses and
imports. The way the module list was created for scope resolution accidentally included
modules used or imported by modules that were privately used or imported. For
instance, in the following use chain, if A were to be used by another module
Main, we would expect only A's contents to be visible to Main:
A -> private use B -> use C
However, we were both including the use of B and including B's use of C, when
the use of B was private. This change makes it so that we stop including a
chain when we see the root of it is private.
Unfortunately, we have to cut off exploration in two places. We have to cut
it in the recursive case of
buildBreadthFirstUseImportList, and we have to
recognize when our entry point into building the list would already be violating
that tactic. The former will have a broader impact on scope resolution, the
latter will only matter for validating use and import lists (because if we're
looking at the contents of a use or import list, we know we're starting in the
middle of a chain).
As a result, 17 tests needed an update because they were relying on the
privacy of a use or import statement being violated. In many of these tests,
the solution was to make the use or import in question public to maintain prior
behavior. Also, resolves the future tracking this issue, and adds a version for
except lists and import lists, as well as the more specific "this" case that Bryant
Passed a full paratest with futures.
Modified Files: A test/visibility/except/errorWhenBehindPrivateImport.chpl