Branch: refs/heads/main
Revision: baacc72
Author: mppf
Link: https://github.com/chapel-lang/chapel/pull/19306
Log Message:
Merge pull request #19306 from mppf/use-shadow-scopes
simplify use/import shadowing
This PR describes and implements some candidate language adjustments to
shadowing behavior for use and import statements. We need to do something
in this area because the definition of shadowing is currently
inconsistent between variables and functions (#19167). This PR attempts
to simplify the language design in this area.
The adjustments to the language design in this PR are as follows:
- isMoreVisible in function disambiguation as well as scope resolution
use the same rules for determining shadowing with use/import
statements - isMoreVisible starts it search from the POI where the candidates were
discovered (see issue #19198 -- not discussed further here) - private use statements still have two shadow scopes
- public and private import statements now do not introduce a shadow
scope - public use statements now do not introduce a shadow scope
-
public use M
does not bring inM
(butpublic use M as M
does) - methods are no longer subject to shadowing
Note that the above design leads to less shadowing of symbols from the
automatic library (see the section "Less Shadowing of Symbols from the
Automatic Standard Library" in
simplify use/import shadowing by mppf · Pull Request #19306 · chapel-lang/chapel · GitHub)
Discussion
Elements of the language design direction are discussed in these issues:
- #19167
- #19160
- #19219 and #13925
- #19312
- #19352
Please see also
which discusses pros and cons of these language design choices.
Testing and Review
Reviewed by @lydia-duncan - thanks!
This PR passes full local futures testing.
Resolves the future test/modules/vass/use-depth.chpl
.
Also fixes #19198 and adds a test based on the case in that issue.
- [x] full local futures testing
- [x] gasnet testing
Future Work
There are two areas of future work that we would like to address soon:
-
#19313 which relates to changes in this PR to the test
modules/bradc/userInsteadOfStandard/foo2
. The behavior for trying to
replace a standard module has changed (presumably due to minor changes
in how the usual standard modules are now available). I think that
changing the compiler to separately list each standard module would
bring the behavior back the way it was. (Or we could look for other
implementation changes to support it). -
#19780 to add warnings for cases where the difference between
public use M
andprivate use M
might be surprisingModified Files:
A test/functions/deitz/test_resolve_best_shadowed2b.chpl
A test/functions/deitz/test_resolve_best_shadowed2b.good
A test/functions/generic/poi/check-gc-reuse-funs.chpl
A test/functions/generic/poi/check-gc-reuse-funs.good
A test/functions/generic/poi/check-gc-reuse-methods.chpl
A test/functions/generic/poi/check-gc-reuse-methods.good
A test/functions/generic/poi/issue-19198.chpl
A test/functions/generic/poi/issue-19198.good
A test/functions/generic/poi/issue-19198m.chpl
A test/functions/generic/poi/issue-19198m.good
A test/modules/shadowing/issue-19167-0.chpl
A test/modules/shadowing/issue-19167-0.good
A test/modules/shadowing/issue-19167-1-f.chpl
A test/modules/shadowing/issue-19167-1-f.good
A test/modules/shadowing/issue-19167-1-x.chpl
A test/modules/shadowing/issue-19167-1-x.good
A test/modules/shadowing/issue-19167-2-f.chpl
A test/modules/shadowing/issue-19167-2-f.good
A test/modules/shadowing/issue-19167-2-x.chpl
A test/modules/shadowing/issue-19167-2-x.good
A test/modules/shadowing/issue-19167-3-f.chpl
A test/modules/shadowing/issue-19167-3-f.good
A test/modules/shadowing/issue-19167-3-x.chpl
A test/modules/shadowing/issue-19167-3-x.good
A test/modules/shadowing/issue-19167-4-f.chpl
A test/modules/shadowing/issue-19167-4-f.good
A test/modules/shadowing/issue-19167-4-x.chpl
A test/modules/shadowing/issue-19167-4-x.good
A test/modules/shadowing/issue-19167-5-f.chpl
A test/modules/shadowing/issue-19167-5-f.good
A test/modules/shadowing/issue-19167-5-x.chpl
A test/modules/shadowing/issue-19167-5-x.good
A test/modules/shadowing/issue-19167-6-f.chpl
A test/modules/shadowing/issue-19167-6-f.good
A test/modules/shadowing/issue-19167-7-x.chpl
A test/modules/shadowing/issue-19167-7-x.good
A test/modules/shadowing/issue-19352-1.chpl
A test/modules/shadowing/issue-19352-1.good
A test/modules/shadowing/issue-19352-2a.chpl
A test/modules/shadowing/issue-19352-2a.good
A test/modules/shadowing/issue-19352-2b.chpl
A test/modules/shadowing/issue-19352-2b.good
A test/modules/shadowing/issue-19352-3.chpl
A test/modules/shadowing/issue-19352-3.good
A test/modules/shadowing/var-shadows-private-import.chpl
A test/modules/shadowing/var-shadows-private-import.good
A test/modules/shadowing/var-shadows-private-use.chpl
A test/modules/shadowing/var-shadows-private-use.good
A test/modules/shadowing/var-shadows-public-import.chpl
A test/modules/shadowing/var-shadows-public-import.good
A test/modules/shadowing/var-shadows-public-use.chpl
A test/modules/shadowing/var-shadows-public-use.good
A test/modules/use/issue-19219.chpl
A test/modules/use/issue-19219.good
A test/optimizations/autoLocalAccess/differentButAlignedDoms.compopts
A test/optimizations/autoLocalAccess/elemAsIndex.compopts
A test/optimizations/autoLocalAccess/localArrays-1D-COO.good
A test/optimizations/autoLocalAccess/localArrays-1D-DR.good
A test/optimizations/autoLocalAccess/localArrays-2D-COO.good
A test/optimizations/autoLocalAccess/localArrays-2D-DR.good
A test/optimizations/autoLocalAccess/localArrays-CSC.good
A test/optimizations/autoLocalAccess/localArrays-CSR.good
A test/optimizations/autoLocalAccess/localArrays-assoc.good
A test/optimizations/autoLocalAccess/localArrays.compopts
A test/optimizations/autoLocalAccess/localArrays.prediff
A test/optimizations/autoLocalAccess/preventMultiCall.compopts
A test/optimizations/autoLocalAccess/preventMultiCallIter.compopts
A test/optimizations/autoLocalAccess/views.compopts
A test/optimizations/autoLocalAccess/views.prediff
A test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.compopts
A test/optimizations/autoLocalAccess/zipper/elemAsIndex.compopts
A test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.compopts
A test/optimizations/autoLocalAccess/zipper/preventMultiCall.compopts
A test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.compopts
A test/optimizations/autoLocalAccess/zipper/views.compopts
A test/optimizations/autoLocalAccess/zipper/views.prediff
A test/visibility/import/edgeCases/anotherMultipleDef2.chpl
A test/visibility/import/edgeCases/anotherMultipleDef2.good
A test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.chpl
A test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.good
A test/visibility/only/warn-public-use-only.chpl
A test/visibility/only/warn-public-use-only.good
A test/visibility/rename/renameUsedMod/renamePublicUse4.chpl
A test/visibility/rename/renameUsedMod/renamePublicUse4.good
A test/visibility/use-no-qualified/public-use-no-mod1.chpl
A test/visibility/use-no-qualified/public-use-no-mod1.good
A test/visibility/use-no-qualified/public-use-no-mod2.chpl
A test/visibility/use-no-qualified/public-use-no-mod2.good
R test/functions/generic/poi/check-gc-reuse-funmets.chpl
R test/functions/generic/poi/check-gc-reuse-funmets.good
R test/modules/vass/use-depth.bad
R test/modules/vass/use-depth.future
R test/optimizations/autoLocalAccess/localArrays.good
M compiler/AST/UseStmt.cpp
M compiler/AST/baseAST.cpp
M compiler/include/UseStmt.h
M compiler/include/resolution.h
M compiler/include/scopeResolve.h
M compiler/passes/checkParsed.cpp
M compiler/passes/scopeResolve.cpp
M compiler/resolution/functionResolution.cpp
M compiler/resolution/resolveFunction.cpp
M doc/rst/language/spec/modules.rst
M modules/dists/DimensionalDist2D.chpl
M modules/internal/ChapelArray.chpl
M modules/internal/ChapelLocale.chpl
M modules/internal/ChapelStandard.chpl
M modules/internal/ChapelTaskID.chpl
M test/classes/assignments/noAssignClass.good
M test/classes/diten/breakList.good
M test/classes/lydia/resolution-nested-method-outer-module.good
M test/classes/lydia/resolution-nested-method.good
M test/constrained-generics/random/MyRandom.chpl
M test/functions/deitz/test_resolve_best_shadowed2.chpl
M test/functions/deitz/test_resolve_best_shadowed2.good
M test/functions/ferguson/hijacking/Application8.good
M test/functions/generic/poi/check-gc-reuse-opers.chpl
M test/functions/generic/poi/check-gc-reuse-opers.good
M test/functions/hilde/inlineKeyword.chpl
M test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/read.chpl
M test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/write.chpl
M test/library/standard/GMP/ldelaney/gmp_Bigint_division.chpl
M test/modules/bradc/userInsteadOfStandard/foo2.good
M test/modules/diten/test_use_chain_resolution.chpl
M test/modules/diten/test_use_chain_resolution.good
M test/modules/vass/use-depth.good
M test/npb/ft/npadmana/DistributedFFT.chpl
M test/optimizations/autoLocalAccess/differentButAlignedDoms.chpl
M test/optimizations/autoLocalAccess/differentButAlignedDoms.good
M test/optimizations/autoLocalAccess/elemAsIndex.chpl
M test/optimizations/autoLocalAccess/elemAsIndex.good
M test/optimizations/autoLocalAccess/flags-full.good
M test/optimizations/autoLocalAccess/flags-none.good
M test/optimizations/autoLocalAccess/flags-staticonly.good
M test/optimizations/autoLocalAccess/flags.chpl
M test/optimizations/autoLocalAccess/flags.compopts
M test/optimizations/autoLocalAccess/localArrays.chpl
M test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.chpl
M test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.good
M test/optimizations/autoLocalAccess/preventMultiCall.chpl
M test/optimizations/autoLocalAccess/preventMultiCall.good
M test/optimizations/autoLocalAccess/preventMultiCallIter.chpl
M test/optimizations/autoLocalAccess/preventMultiCallIter.good
M test/optimizations/autoLocalAccess/views.chpl
M test/optimizations/autoLocalAccess/views.good
M test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.chpl
M test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.good
M test/optimizations/autoLocalAccess/zipper/elemAsIndex.chpl
M test/optimizations/autoLocalAccess/zipper/elemAsIndex.good
M test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.chpl
M test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.good
M test/optimizations/autoLocalAccess/zipper/preventMultiCall.chpl
M test/optimizations/autoLocalAccess/zipper/preventMultiCall.good
M test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.chpl
M test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.good
M test/optimizations/autoLocalAccess/zipper/views.chpl
M test/optimizations/autoLocalAccess/zipper/views.good
M test/parallel/taskPar/sungeun/private.chpl
M test/performance/thomasvandoren/TestHelpers.chpl
M test/reductions/thomasvandoren/scanCountsInherit.chpl
M test/reductions/thomasvandoren/sorted.chpl
M test/release/examples/primers/modules.chpl
M test/release/examples/primers/modules.good
M test/studies/cholesky/jglewis/version2/elemental/fully_blocked/elemental_cholesky_fully_blocked.chpl
M test/studies/cholesky/jglewis/version2/elemental/fully_blocked/test_fully_blocked_elemental_cholesky.chpl
M test/studies/shootout/pidigits/thomasvandoren/pidigits-BigInt.chpl
M test/types/coerce/diten/test_override_equals.chpl
M test/types/enum/lydia/use/useMultiple.chpl
M test/types/scalar/bradc/bitNegateBoolUserDefined.chpl
M test/types/string/sungeun/c_string/casts.chpl
M test/types/string/sungeun/c_string/concat.chpl
M test/types/string/sungeun/c_string/decls.chpl
M test/visibility/empty/onlyNothingField.chpl
M test/visibility/empty/onlyNothingField.good
M test/visibility/except/deepUseWouldConflict.chpl
M test/visibility/except/deepUseWouldConflict.good
M test/visibility/import/edgeCases/anotherMultipleDef.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2a.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2b.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2c.chpl
M test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2d.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useExcept1a.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useExcept1b.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useExcept1c.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useExcept1d.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnly1a.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnly1b.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnly1c.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnly1d.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1a.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1b.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2a.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2b.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2c.chpl
M test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2d.chpl
M test/visibility/import/enablesUnqualified/useAndImport.chpl
M test/visibility/import/enablesUnqualified/useAndImport2.chpl
M test/visibility/import/public/qualifiedReexport/importAndImportFromUse.good
M test/visibility/import/public/useAndImport-useOnlyNothing1a.chpl
M test/visibility/import/public/useAndImport-useOnlyNothing1b.chpl
M test/visibility/import/public/useAndImport-useOnlyNothing2a.chpl
M test/visibility/import/public/useAndImport-useOnlyNothing2b.chpl
M test/visibility/import/public/useAndImport-useOnlyNothing2c.chpl
M test/visibility/import/public/useAndImport-useOnlyNothing2d.chpl
M test/visibility/import/rename/same_name_in_mod.good
M test/visibility/import/rename/same_name_in_mod2.good
M test/visibility/import/useAndImport-useExcept1a.good
M test/visibility/import/useAndImport-useExcept1b.good
M test/visibility/import/useAndImport-useExcept1c.good
M test/visibility/import/useAndImport-useExcept1d.good
M test/visibility/import/useAndImport-useOnly1a.good
M test/visibility/import/useAndImport-useOnly1b.good
M test/visibility/import/useAndImport-useOnly1c.good
M test/visibility/import/useAndImport-useOnly1d.good
M test/visibility/import/useAndImport-useOnlyNothing1a.chpl
M test/visibility/import/useAndImport-useOnlyNothing1a.good
M test/visibility/import/useAndImport-useOnlyNothing1b.chpl
M test/visibility/import/useAndImport-useOnlyNothing1b.good
M test/visibility/import/useAndImport-useOnlyNothing2a.chpl
M test/visibility/import/useAndImport-useOnlyNothing2b.chpl
M test/visibility/import/useAndImport-useOnlyNothing2c.chpl
M test/visibility/import/useAndImport-useOnlyNothing2d.chpl
M test/visibility/import/useAndImport.good
M test/visibility/import/useAndImport2.good
M test/visibility/private/uses/definesMultiUse.chpl
M test/visibility/private/uses/weirdEnumHiding.chpl
M tools/mason/MasonPublish.chplCompare: Comparing fa4f6a6ce6a6...baacc72cf629 · chapel-lang/chapel · GitHub