From bb26de130534334dd5d4e149169ac710af06b560 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 18 Feb 2022 14:48:18 -0500 Subject: [PATCH 01/96] Ambiguity error for module defining sym with same name --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 10 ++++++++++ modules/internal/ChapelLocale.chpl | 2 +- modules/internal/ChapelStandard.chpl | 2 +- test/modules/use/issue-19219.chpl | 11 +++++++++++ test/modules/use/issue-19219.good | 2 ++ 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test/modules/use/issue-19219.chpl create mode 100644 test/modules/use/issue-19219.good diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index ff7748996fbe..2810fc09fe09 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -2018,6 +2018,16 @@ bool lookupThisScopeAndUses(const char* name, forv_Vec(Stmt, stmt, *moduleUses) { if (UseStmt* use = toUseStmt(stmt)) { + // Check to see if the module name matches what is use'd + if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && use->isARename()) { + renameLocs[modSym] = &use->astloc; + } + } + } + if (use->skipSymbolSearch(name) == false) { const char* nameToUse = use->isARenamedSym(name) ? use->getRenamedSym(name) : name; diff --git a/modules/internal/ChapelLocale.chpl b/modules/internal/ChapelLocale.chpl index 4dcc4c8fd56e..0b7a7e779e53 100644 --- a/modules/internal/ChapelLocale.chpl +++ b/modules/internal/ChapelLocale.chpl @@ -26,7 +26,7 @@ */ module ChapelLocale { - public use LocaleModel; + public use LocaleModel as _; // let LocaleModel refer to the class import HaltWrappers; use CTypes; diff --git a/modules/internal/ChapelStandard.chpl b/modules/internal/ChapelStandard.chpl index f8097543afac..09b30bd159d9 100644 --- a/modules/internal/ChapelStandard.chpl +++ b/modules/internal/ChapelStandard.chpl @@ -44,7 +44,7 @@ module ChapelStandard { public use ChapelReduce; public use ChapelSyncvar; public use ChapelTaskDataHelp; - public use LocaleModel; + public use LocaleModel as _; // let LocaleModel refer to the class public use ChapelLocale; public use ChapelPrivatization; public use DefaultRectangular; // This might be able to go just after Atomics diff --git a/test/modules/use/issue-19219.chpl b/test/modules/use/issue-19219.chpl new file mode 100644 index 000000000000..2a4195441116 --- /dev/null +++ b/test/modules/use/issue-19219.chpl @@ -0,0 +1,11 @@ +module M { + var M: int; +} + +module N { + use M; + + proc main() { + writeln(M); + } +} diff --git a/test/modules/use/issue-19219.good b/test/modules/use/issue-19219.good new file mode 100644 index 000000000000..bbb89e7218c4 --- /dev/null +++ b/test/modules/use/issue-19219.good @@ -0,0 +1,2 @@ +issue-19219.chpl:1: error: symbol M is multiply defined +issue-19219.chpl:2: note: also defined here From 60e8b732f511676dc5839da4e4bef53efe8efcf6 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 18 Feb 2022 15:07:22 -0500 Subject: [PATCH 02/96] Only private use has shadow scope public use, public import, private import do not have shadow scope --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 269 ++++++++++-------- .../use/var-shadows-private-import.chpl | 12 + .../use/var-shadows-private-import.good | 2 + test/modules/use/var-shadows-private-use.chpl | 12 + test/modules/use/var-shadows-private-use.good | 1 + .../use/var-shadows-public-import.chpl | 12 + .../use/var-shadows-public-import.good | 2 + test/modules/use/var-shadows-public-use.chpl | 12 + test/modules/use/var-shadows-public-use.good | 2 + 9 files changed, 210 insertions(+), 114 deletions(-) create mode 100644 test/modules/use/var-shadows-private-import.chpl create mode 100644 test/modules/use/var-shadows-private-import.good create mode 100644 test/modules/use/var-shadows-private-use.chpl create mode 100644 test/modules/use/var-shadows-private-use.good create mode 100644 test/modules/use/var-shadows-public-import.chpl create mode 100644 test/modules/use/var-shadows-public-import.good create mode 100644 test/modules/use/var-shadows-public-use.chpl create mode 100644 test/modules/use/var-shadows-public-use.good diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 2810fc09fe09..727f0d518165 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -1955,6 +1955,15 @@ static bool skipUse(std::map >* seen, static bool skipUse(std::map >* seen, ImportStmt* current); +static void lookupUseImport(const char* name, + BaseAST* context, + BaseAST* scope, + std::vector& symbols, + std::map& renameLocs, + bool storeRenames, + std::map& reexportPts, + bool forShadowScope); + static bool lookupThisScopeAndUses(const char* name, BaseAST* context, @@ -1986,150 +1995,183 @@ bool lookupThisScopeAndUses(const char* name, symbols.push_back(sym); } + // check public use/imports + lookupUseImport(name, context, scope, symbols, + renameLocs, storeRenames, reexportPts, + /* forShadowScope */ false); + if (symbols.size() == 0) { - // Nothing found so far, look into the uses. - if (BlockStmt* block = toBlockStmt(scope)) { - if (block->useList != NULL) { - Vec* moduleUses = NULL; + // check private use only + lookupUseImport(name, context, scope, symbols, + renameLocs, storeRenames, reexportPts, + /* forShadowScope */ true); + } - if (moduleUsesCache.count(block) == 0) { - moduleUses = new Vec(); + return symbols.size() != 0; +} - for_actuals(expr, block->useList) { - // Ensure we only have use or import statements in this list - if (UseStmt* use = toUseStmt(expr)) { - moduleUses->add(use); - } else if (ImportStmt* import = toImportStmt(expr)) { - moduleUses->add(import); - } else { - INT_FATAL("Bad contents for useList, expected use or import"); - } +static void lookupUseImport(const char* name, + BaseAST* context, + BaseAST* scope, + std::vector& symbols, + std::map& renameLocs, + bool storeRenames, + std::map& reexportPts, + bool forShadowScope) { + // Nothing found so far, look into the uses. + if (BlockStmt* block = toBlockStmt(scope)) { + if (block->useList != NULL) { + Vec* moduleUses = NULL; + + if (moduleUsesCache.count(block) == 0) { + moduleUses = new Vec(); + + for_actuals(expr, block->useList) { + // Ensure we only have use or import statements in this list + if (UseStmt* use = toUseStmt(expr)) { + moduleUses->add(use); + } else if (ImportStmt* import = toImportStmt(expr)) { + moduleUses->add(import); + } else { + INT_FATAL("Bad contents for useList, expected use or import"); } + } - INT_ASSERT(moduleUses->n); + INT_ASSERT(moduleUses->n); - buildBreadthFirstModuleList(moduleUses); + buildBreadthFirstModuleList(moduleUses); - if (enableModuleUsesCache) - moduleUsesCache[block] = moduleUses; - } else { - moduleUses = moduleUsesCache[block]; + if (enableModuleUsesCache) + moduleUsesCache[block] = moduleUses; + } else { + moduleUses = moduleUsesCache[block]; + } + + forv_Vec(Stmt, stmt, *moduleUses) { + bool checkThisInShadowScope = false; + if (UseStmt* use = toUseStmt(stmt)) { + if (use->isPrivate) + checkThisInShadowScope = true; } - forv_Vec(Stmt, stmt, *moduleUses) { - if (UseStmt* use = toUseStmt(stmt)) { - // Check to see if the module name matches what is use'd - if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { - if (isRepeat(modSym, symbols) == false) { - symbols.push_back(modSym); - if (storeRenames && use->isARename()) { - renameLocs[modSym] = &use->astloc; - } + // Skip for now things that don't match the request + // to find use/import for the shadow scope (or not). + // (these will be handled in a different call to this function) + if (forShadowScope != checkThisInShadowScope) + continue; + + if (UseStmt* use = toUseStmt(stmt)) { + // Check to see if the module name matches what is use'd + if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && use->isARename()) { + renameLocs[modSym] = &use->astloc; } } + } - if (use->skipSymbolSearch(name) == false) { - const char* nameToUse = use->isARenamedSym(name) ? - use->getRenamedSym(name) : name; - BaseAST* scopeToUse = use->getSearchScope(); - - Symbol* sym = inSymbolTable(nameToUse, scopeToUse); - if (!sym && use->canReexport) { - if (ResolveScope* rs = ResolveScope::getScopeFor(scopeToUse)) { - sym = rs->lookupPublicUnqualAccessSyms(nameToUse, context, - renameLocs, - reexportPts, false); - // propagate this information to the UseStmt - if (!rs->canReexport) { - use->canReexport = false; - } + if (use->skipSymbolSearch(name) == false) { + const char* nameToUse = use->isARenamedSym(name) ? + use->getRenamedSym(name) : name; + BaseAST* scopeToUse = use->getSearchScope(); + + Symbol* sym = inSymbolTable(nameToUse, scopeToUse); + if (!sym && use->canReexport) { + if (ResolveScope* rs = ResolveScope::getScopeFor(scopeToUse)) { + sym = rs->lookupPublicUnqualAccessSyms(nameToUse, context, + renameLocs, + reexportPts, false); + // propagate this information to the UseStmt + if (!rs->canReexport) { + use->canReexport = false; } } - if (sym) { - if (sym->hasFlag(FLAG_PRIVATE) == true) { - if (sym->isVisible(context) == true && - isRepeat(sym, symbols) == false) { - symbols.push_back(sym); - if (storeRenames && use->isARenamedSym(name)) { - renameLocs[sym] = &use->astloc; - } - } - - } else if (isRepeat(sym, symbols) == false) { + } + if (sym) { + if (sym->hasFlag(FLAG_PRIVATE) == true) { + if (sym->isVisible(context) == true && + isRepeat(sym, symbols) == false) { symbols.push_back(sym); if (storeRenames && use->isARenamedSym(name)) { renameLocs[sym] = &use->astloc; } } + + } else if (isRepeat(sym, symbols) == false) { + symbols.push_back(sym); + if (storeRenames && use->isARenamedSym(name)) { + renameLocs[sym] = &use->astloc; + } } } - } else if (ImportStmt* import = toImportStmt(stmt)) { - // Only traverse import statements that define a symbol with this - // name for unqualified access. We're only looking for explicitly - // named symbols - if (import->skipSymbolSearch(name) == false) { - const char* nameToUse = import->isARenamedSym(name) ? - import->getRenamedSym(name) : name; - BaseAST* scopeToUse = import->getSearchScope(); - if (Symbol* sym = inSymbolTable(nameToUse, scopeToUse)) { - if (sym->hasFlag(FLAG_PRIVATE) == true) { - if (sym->isVisible(context) == true && - isRepeat(sym, symbols) == false) { - symbols.push_back(sym); - if (storeRenames && import->isARenamedSym(name)) { - renameLocs[sym] = &import->astloc; - } - } - } else if (isRepeat(sym, symbols) == false) { + } + } else if (ImportStmt* import = toImportStmt(stmt)) { + // Only traverse import statements that define a symbol with this + // name for unqualified access. We're only looking for explicitly + // named symbols + if (import->skipSymbolSearch(name) == false) { + const char* nameToUse = import->isARenamedSym(name) ? + import->getRenamedSym(name) : name; + BaseAST* scopeToUse = import->getSearchScope(); + if (Symbol* sym = inSymbolTable(nameToUse, scopeToUse)) { + if (sym->hasFlag(FLAG_PRIVATE) == true) { + if (sym->isVisible(context) == true && + isRepeat(sym, symbols) == false) { symbols.push_back(sym); if (storeRenames && import->isARenamedSym(name)) { renameLocs[sym] = &import->astloc; } } + } else if (isRepeat(sym, symbols) == false) { + symbols.push_back(sym); + if (storeRenames && import->isARenamedSym(name)) { + renameLocs[sym] = &import->astloc; + } } } - } else { - // break on each new depth if a symbol has been found - if (symbols.size() > 0) { - break; - } + } + } else { + // break on each new depth if a symbol has been found + if (symbols.size() > 0) { + break; } } + } - if (symbols.size() > 0) { - // We found a symbol in the module use. This could conflict with - // the function symbol's arguments if we are at the top level scope - // within a function. Note that we'd check the next scope up if - // size() == 0, so we only need to do this check here because the - // module case would hide it otherwise - if (FnSymbol* fn = toFnSymbol(getScope(block))) { - // The next scope up from the block statement is a function - // symbol. That means that we need to check the arguments - if (Symbol* sym = inSymbolTable(name, fn)) { - // We found it in the arguments. This should cause a conflict, - // because it is probably an error that the user had the same - // name as a module level variable. - USR_WARN(sym, - "Module level symbol is hiding function argument '%s'", - name); - } + if (symbols.size() > 0) { + // We found a symbol in the module use. This could conflict with + // the function symbol's arguments if we are at the top level scope + // within a function. Note that we'd check the next scope up if + // size() == 0, so we only need to do this check here because the + // module case would hide it otherwise + if (FnSymbol* fn = toFnSymbol(getScope(block))) { + // The next scope up from the block statement is a function + // symbol. That means that we need to check the arguments + if (Symbol* sym = inSymbolTable(name, fn)) { + // We found it in the arguments. This should cause a conflict, + // because it is probably an error that the user had the same + // name as a module level variable. + USR_WARN(sym, + "Module level symbol is hiding function argument '%s'", + name); } - } else { - // we haven't found a match yet, so as a last resort, let's - // check the names of the modules in the 'use'/'import' statements - // themselves... This effectively places the module names at - // a scope just a bit further out than the one holding the - // symbols that they define. - forv_Vec(VisibilityStmt, stmt, *moduleUses) { - if (stmt != NULL) { - if (!isImportStmt(stmt) || - toImportStmt(stmt)->providesQualifiedAccess()) { - if (Symbol* modSym = stmt->checkIfModuleNameMatches(name)) { - if (isRepeat(modSym, symbols) == false) { - symbols.push_back(modSym); - if (storeRenames && stmt->isARename()) { - renameLocs[modSym] = &stmt->astloc; - } + } + } else { + // we haven't found a match yet, so as a last resort, let's + // check the names of the modules in the 'use'/'import' statements + // themselves... This effectively places the module names at + // a scope just a bit further out than the one holding the + // symbols that they define. + forv_Vec(VisibilityStmt, stmt, *moduleUses) { + if (stmt != NULL) { + if (!isImportStmt(stmt) || + toImportStmt(stmt)->providesQualifiedAccess()) { + if (Symbol* modSym = stmt->checkIfModuleNameMatches(name)) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && stmt->isARename()) { + renameLocs[modSym] = &stmt->astloc; } } } @@ -2139,10 +2181,9 @@ bool lookupThisScopeAndUses(const char* name, } } } - - return symbols.size() != 0; } + // Returns true if the symbol is present in the vector, false otherwise static bool isRepeat(Symbol* toAdd, const std::vector& symbols) { for (std::vector::const_iterator it = symbols.begin(); diff --git a/test/modules/use/var-shadows-private-import.chpl b/test/modules/use/var-shadows-private-import.chpl new file mode 100644 index 000000000000..9f766103c10f --- /dev/null +++ b/test/modules/use/var-shadows-private-import.chpl @@ -0,0 +1,12 @@ +module M { + var x: int; +} + +module N { + private import M.x; + var x: int; + + proc main() { + writeln(x); + } +} diff --git a/test/modules/use/var-shadows-private-import.good b/test/modules/use/var-shadows-private-import.good new file mode 100644 index 000000000000..46c11e1e8844 --- /dev/null +++ b/test/modules/use/var-shadows-private-import.good @@ -0,0 +1,2 @@ +var-shadows-private-import.chpl:7: error: symbol x is multiply defined +var-shadows-private-import.chpl:2: note: also defined here diff --git a/test/modules/use/var-shadows-private-use.chpl b/test/modules/use/var-shadows-private-use.chpl new file mode 100644 index 000000000000..851885517077 --- /dev/null +++ b/test/modules/use/var-shadows-private-use.chpl @@ -0,0 +1,12 @@ +module M { + var x: int; +} + +module N { + private use M; + var x: int; + + proc main() { + writeln(x); + } +} diff --git a/test/modules/use/var-shadows-private-use.good b/test/modules/use/var-shadows-private-use.good new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/test/modules/use/var-shadows-private-use.good @@ -0,0 +1 @@ +0 diff --git a/test/modules/use/var-shadows-public-import.chpl b/test/modules/use/var-shadows-public-import.chpl new file mode 100644 index 000000000000..981884646cf5 --- /dev/null +++ b/test/modules/use/var-shadows-public-import.chpl @@ -0,0 +1,12 @@ +module M { + var x: int; +} + +module N { + public import M.x; + var x: int; + + proc main() { + writeln(x); + } +} diff --git a/test/modules/use/var-shadows-public-import.good b/test/modules/use/var-shadows-public-import.good new file mode 100644 index 000000000000..56c78d43b41a --- /dev/null +++ b/test/modules/use/var-shadows-public-import.good @@ -0,0 +1,2 @@ +var-shadows-public-import.chpl:7: error: symbol x is multiply defined +var-shadows-public-import.chpl:2: note: also defined here diff --git a/test/modules/use/var-shadows-public-use.chpl b/test/modules/use/var-shadows-public-use.chpl new file mode 100644 index 000000000000..d6387ef3f5f3 --- /dev/null +++ b/test/modules/use/var-shadows-public-use.chpl @@ -0,0 +1,12 @@ +module M { + var x: int; +} + +module N { + public use M; + var x: int; + + proc main() { + writeln(x); + } +} diff --git a/test/modules/use/var-shadows-public-use.good b/test/modules/use/var-shadows-public-use.good new file mode 100644 index 000000000000..02eec7334a71 --- /dev/null +++ b/test/modules/use/var-shadows-public-use.good @@ -0,0 +1,2 @@ +var-shadows-public-use.chpl:7: error: symbol x is multiply defined +var-shadows-public-use.chpl:2: note: also defined here From be01731f351a0ef8886c304a4bb937c4361f6286 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 18 Feb 2022 15:49:58 -0500 Subject: [PATCH 03/96] Move new tests to modules/shadowing --- Signed-off-by: Michael Ferguson --- test/modules/{use => shadowing}/var-shadows-private-import.chpl | 0 test/modules/{use => shadowing}/var-shadows-private-import.good | 0 test/modules/{use => shadowing}/var-shadows-private-use.chpl | 0 test/modules/{use => shadowing}/var-shadows-private-use.good | 0 test/modules/{use => shadowing}/var-shadows-public-import.chpl | 0 test/modules/{use => shadowing}/var-shadows-public-import.good | 0 test/modules/{use => shadowing}/var-shadows-public-use.chpl | 0 test/modules/{use => shadowing}/var-shadows-public-use.good | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename test/modules/{use => shadowing}/var-shadows-private-import.chpl (100%) rename test/modules/{use => shadowing}/var-shadows-private-import.good (100%) rename test/modules/{use => shadowing}/var-shadows-private-use.chpl (100%) rename test/modules/{use => shadowing}/var-shadows-private-use.good (100%) rename test/modules/{use => shadowing}/var-shadows-public-import.chpl (100%) rename test/modules/{use => shadowing}/var-shadows-public-import.good (100%) rename test/modules/{use => shadowing}/var-shadows-public-use.chpl (100%) rename test/modules/{use => shadowing}/var-shadows-public-use.good (100%) diff --git a/test/modules/use/var-shadows-private-import.chpl b/test/modules/shadowing/var-shadows-private-import.chpl similarity index 100% rename from test/modules/use/var-shadows-private-import.chpl rename to test/modules/shadowing/var-shadows-private-import.chpl diff --git a/test/modules/use/var-shadows-private-import.good b/test/modules/shadowing/var-shadows-private-import.good similarity index 100% rename from test/modules/use/var-shadows-private-import.good rename to test/modules/shadowing/var-shadows-private-import.good diff --git a/test/modules/use/var-shadows-private-use.chpl b/test/modules/shadowing/var-shadows-private-use.chpl similarity index 100% rename from test/modules/use/var-shadows-private-use.chpl rename to test/modules/shadowing/var-shadows-private-use.chpl diff --git a/test/modules/use/var-shadows-private-use.good b/test/modules/shadowing/var-shadows-private-use.good similarity index 100% rename from test/modules/use/var-shadows-private-use.good rename to test/modules/shadowing/var-shadows-private-use.good diff --git a/test/modules/use/var-shadows-public-import.chpl b/test/modules/shadowing/var-shadows-public-import.chpl similarity index 100% rename from test/modules/use/var-shadows-public-import.chpl rename to test/modules/shadowing/var-shadows-public-import.chpl diff --git a/test/modules/use/var-shadows-public-import.good b/test/modules/shadowing/var-shadows-public-import.good similarity index 100% rename from test/modules/use/var-shadows-public-import.good rename to test/modules/shadowing/var-shadows-public-import.good diff --git a/test/modules/use/var-shadows-public-use.chpl b/test/modules/shadowing/var-shadows-public-use.chpl similarity index 100% rename from test/modules/use/var-shadows-public-use.chpl rename to test/modules/shadowing/var-shadows-public-use.chpl diff --git a/test/modules/use/var-shadows-public-use.good b/test/modules/shadowing/var-shadows-public-use.good similarity index 100% rename from test/modules/use/var-shadows-public-use.good rename to test/modules/shadowing/var-shadows-public-use.good From 095a8989a31348bfcbb17768706c04db938a19d7 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 18 Feb 2022 15:50:15 -0500 Subject: [PATCH 04/96] Make isMoreVisible in disambiguation consistent --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 172 ++++++++++++++------- test/modules/shadowing/issue-19167-1.chpl | 15 ++ test/modules/shadowing/issue-19167-1.good | 2 + 3 files changed, 137 insertions(+), 52 deletions(-) create mode 100644 test/modules/shadowing/issue-19167-1.chpl create mode 100644 test/modules/shadowing/issue-19167-1.good diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 5317e6dbb24e..f6042575c950 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -1819,90 +1819,157 @@ getParentBlock(Expr* expr) { return NULL; } +enum MoreVisibleResult { + FOUND_F1_FIRST, + FOUND_F2_FIRST, + FOUND_BOTH, + FOUND_NEITHER +}; // -// helper routine for isMoreVisible (below); -// returns true if fn1 is more visible than fn2 +// helper routines for isMoreVisible (below); // -static bool -isMoreVisibleInternal(BlockStmt* block, FnSymbol* fn1, FnSymbol* fn2, - Vec& visited) { - // - // fn1 is more visible - // - if (fn1->defPoint->parentExpr == block) - return true; - // - // fn2 is more visible - // - if (fn2->defPoint->parentExpr == block) - return false; +static bool +isDefinedInBlock(BlockStmt* block, FnSymbol* fn) { + return (fn->defPoint->parentExpr == block); +} - visited.set_add(block); +static bool +isDefinedInUseImport(BlockStmt* block, FnSymbol* fn, + bool allowPrivateUseImp, bool forShadowScope, + Vec& visited) { + if (block && block->useList) { + visited.set_add(block); - // - // return true unless fn2 is more visible, - // including the case where neither are visible - // + for_actuals(expr, block->useList) { + bool checkThisInShadowScope = false; + if (UseStmt* use = toUseStmt(expr)) { + if (use->isPrivate) + checkThisInShadowScope = true; + } - // - // ensure f2 is not more visible via parent block, and recurse - // - if (BlockStmt* parentBlock = getParentBlock(block)) - if (!visited.set_in(parentBlock)) - if (! isMoreVisibleInternal(parentBlock, fn1, fn2, visited)) - return false; + // Skip for now things that don't match the request + // to find use/import for the shadow scope (or not). + // (these will be handled in a different call to this function) + if (forShadowScope != checkThisInShadowScope) + continue; - // - // ensure f2 is not more visible via module uses, and recurse - // - if (block && block->useList) { - for_actuals(expr, block->useList) { + bool isPrivate = false; SymExpr* se = NULL; if (UseStmt* use = toUseStmt(expr)) { se = toSymExpr(use->src); - } else if (ImportStmt* import = toImportStmt(expr)) { - se = toSymExpr(import->src); + isPrivate = use->isPrivate; + } else if (ImportStmt* imp = toImportStmt(expr)) { + se = toSymExpr(imp->src); + isPrivate = imp->isPrivate; } INT_ASSERT(se); - // We only care about uses of modules during function resolution, not - // uses of enums. + + // Skip things that are private when considering a nested use/import + if (isPrivate && !allowPrivateUseImp) + continue; + + // ignore uses of enums here if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { - if (!visited.set_in(mod->block)) - if (! isMoreVisibleInternal(mod->block, fn1, fn2, visited)) - return false; + // is it defined in the use/imported module? + if (isDefinedInBlock(mod->block, fn)) + return true; + // is it defined in something used/imported in that module? + if (!visited.set_in(mod->block)) { + if (isDefinedInUseImport(mod->block, fn, + /* allowPrivateUseImp */ false, + /* forShadowScope */ false, + visited)) + return true; + } } } } - return true; + return false; } +static MoreVisibleResult +isMoreVisibleInternal(BlockStmt* block, FnSymbol* fn1, FnSymbol* fn2, + Vec& visited1, Vec& visited2) { + + if (visited1.set_in(block) && visited2.set_in(block)) + return FOUND_NEITHER; + + // first, check things in the current block or + // from use/import that don't use a shadow scope + bool foundHere1 = isDefinedInBlock(block, fn1) || + isDefinedInUseImport(block, fn1, + /* allowPrivateUseImp */ true, + /* forShadowScope */ false, + visited1); + + bool foundHere2 = isDefinedInBlock(block, fn2) || + isDefinedInUseImport(block, fn2, + /* allowPrivateUseImp */ true, + /* forShadowScope */ false, + visited2); + + if (foundHere1 && foundHere2) + return FOUND_BOTH; + + if (foundHere1) + return FOUND_F1_FIRST; + + if (foundHere2) + return FOUND_F2_FIRST; + + // next, check anything from a use/import in the + // current block that uses a shadow scope + bool foundShadowHere1 = isDefinedInUseImport(block, fn1, + /* allowPrivateUseImp */ true, + /* forShadowScope */ true, + visited1); + + bool foundShadowHere2 = isDefinedInUseImport(block, fn2, + /* allowPrivateUseImp */ true, + /* forShadowScope */ true, + visited2); + + if (foundShadowHere1 && foundShadowHere2) + return FOUND_BOTH; + + if (foundShadowHere1) + return FOUND_F1_FIRST; + + if (foundShadowHere2) + return FOUND_F2_FIRST; + + // next, check parent scope, recursively + if (BlockStmt* parentBlock = getParentBlock(block)) { + return isMoreVisibleInternal(parentBlock, fn1, fn2, visited1, visited2); + } + + return FOUND_NEITHER; +} // -// return true if fn1 is more visible than fn2 from expr -// -// assumption: fn1 and fn2 are visible from expr; if this assumption -// is violated, this function will return true +// return whether fn1 is more visible than fn2 from expr // -static bool +static MoreVisibleResult isMoreVisible(Expr* expr, FnSymbol* fn1, FnSymbol* fn2) { // // common-case check to see if functions have equal visibility // if (fn1->defPoint->parentExpr == fn2->defPoint->parentExpr) { - return false; + return FOUND_BOTH; } // // call helper function with visited set to avoid infinite recursion // - Vec visited; + Vec visited1; + Vec visited2; BlockStmt* block = toBlockStmt(expr); if (!block) block = getParentBlock(expr); - return isMoreVisibleInternal(block, fn1, fn2, visited); + return isMoreVisibleInternal(block, fn1, fn2, visited1, visited2); } @@ -3489,7 +3556,7 @@ static void reportHijackingError(CallExpr* call, { USR_FATAL_CONT(call, "multiple overload sets are applicable to this call"); - if (isMoreVisible(call, candFn, bestFn)) + if (isMoreVisible(call, candFn, bestFn) == FOUND_F1_FIRST) { USR_PRINT(candFn, "instead of the candidate here"); USR_PRINT(candMod, "... defined in this closer module"); @@ -3549,7 +3616,7 @@ static bool overloadSetsOK(CallExpr* call, check_state_t checkState, ModuleSymbol* candMod = overloadSetModule(candidate); if (candMod && candMod != bestMod && - ! isMoreVisible(call, bestFn, candidate->fn) && + isMoreVisible(call, bestFn, candidate->fn) != FOUND_F1_FIRST && ! isAcceptableMethodChoice(call, bestFn, candidate->fn, candidates) ) { if (checkState == CHECK_NORMAL_CALL) @@ -5550,11 +5617,12 @@ static int compareSpecificity(ResolutionCandidate* candidate1, } else { // If the decision hasn't been made based on the argument mappings... - if (isMoreVisible(DC.scope, candidate1->fn, candidate2->fn)) { + auto v = isMoreVisible(DC.scope, candidate1->fn, candidate2->fn); + if (v == FOUND_F1_FIRST) { EXPLAIN("\nQ: preferring more visible function\n"); prefer1 = true; - } else if (isMoreVisible(DC.scope, candidate2->fn, candidate1->fn)) { + } else if (v == FOUND_F2_FIRST) { EXPLAIN("\nR: preferring more visible function\n"); prefer2 = true; diff --git a/test/modules/shadowing/issue-19167-1.chpl b/test/modules/shadowing/issue-19167-1.chpl new file mode 100644 index 000000000000..0ea90a70397a --- /dev/null +++ b/test/modules/shadowing/issue-19167-1.chpl @@ -0,0 +1,15 @@ +module M { + var X: int; + proc f() { writeln("M.f"); } +} + +module N { + var X: real; + proc f() { writeln("N.f"); } + + proc main() { + use M; + writeln(X); // prints out 0 so refers to M.X + f(); // ambiguity error + } +} diff --git a/test/modules/shadowing/issue-19167-1.good b/test/modules/shadowing/issue-19167-1.good new file mode 100644 index 000000000000..cc1d30c19f6e --- /dev/null +++ b/test/modules/shadowing/issue-19167-1.good @@ -0,0 +1,2 @@ +0 +M.f From 4aa6966cab64543e18523595f37a30a9c2f4a554 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 18 Feb 2022 17:16:53 -0500 Subject: [PATCH 05/96] Partial work --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 41 +++++++++++++--- compiler/resolution/functionResolution.cpp | 6 +++ ...{issue-19167-1.chpl => issue-19167-0.chpl} | 0 ...{issue-19167-1.good => issue-19167-0.good} | 0 test/modules/shadowing/issue-19167-1-f.chpl | 47 +++++++++++++++++++ test/modules/shadowing/issue-19167-1-f.good | 4 ++ test/modules/shadowing/issue-19167-1-x.chpl | 47 +++++++++++++++++++ test/modules/shadowing/issue-19167-1-x.good | 2 + test/modules/shadowing/issue-19167-2-f.chpl | 47 +++++++++++++++++++ test/modules/shadowing/issue-19167-2-f.good | 4 ++ test/modules/shadowing/issue-19167-2-x.chpl | 46 ++++++++++++++++++ test/modules/shadowing/issue-19167-2-x.good | 2 + test/modules/shadowing/issue-19167-3-f.chpl | 47 +++++++++++++++++++ test/modules/shadowing/issue-19167-3-f.good | 4 ++ test/modules/shadowing/issue-19167-3-x.chpl | 47 +++++++++++++++++++ test/modules/shadowing/issue-19167-3-x.good | 1 + test/modules/shadowing/issue-19167-4-f.chpl | 47 +++++++++++++++++++ test/modules/shadowing/issue-19167-4-f.good | 4 ++ test/modules/shadowing/issue-19167-4-x.chpl | 47 +++++++++++++++++++ test/modules/shadowing/issue-19167-4-x.good | 2 + test/modules/shadowing/issue-19167-5-f.chpl | 46 ++++++++++++++++++ test/modules/shadowing/issue-19167-5-f.good | 4 ++ test/modules/shadowing/issue-19167-5-x.chpl | 46 ++++++++++++++++++ test/modules/shadowing/issue-19167-5-x.good | 2 + test/modules/shadowing/issue-19167-6-f.chpl | 45 ++++++++++++++++++ test/modules/shadowing/issue-19167-6-f.good | 1 + test/modules/shadowing/issue-19167-7-x.chpl | 45 ++++++++++++++++++ test/modules/shadowing/issue-19167-7-x.good | 1 + 28 files changed, 628 insertions(+), 7 deletions(-) rename test/modules/shadowing/{issue-19167-1.chpl => issue-19167-0.chpl} (100%) rename test/modules/shadowing/{issue-19167-1.good => issue-19167-0.good} (100%) create mode 100644 test/modules/shadowing/issue-19167-1-f.chpl create mode 100644 test/modules/shadowing/issue-19167-1-f.good create mode 100644 test/modules/shadowing/issue-19167-1-x.chpl create mode 100644 test/modules/shadowing/issue-19167-1-x.good create mode 100644 test/modules/shadowing/issue-19167-2-f.chpl create mode 100644 test/modules/shadowing/issue-19167-2-f.good create mode 100644 test/modules/shadowing/issue-19167-2-x.chpl create mode 100644 test/modules/shadowing/issue-19167-2-x.good create mode 100644 test/modules/shadowing/issue-19167-3-f.chpl create mode 100644 test/modules/shadowing/issue-19167-3-f.good create mode 100644 test/modules/shadowing/issue-19167-3-x.chpl create mode 100644 test/modules/shadowing/issue-19167-3-x.good create mode 100644 test/modules/shadowing/issue-19167-4-f.chpl create mode 100644 test/modules/shadowing/issue-19167-4-f.good create mode 100644 test/modules/shadowing/issue-19167-4-x.chpl create mode 100644 test/modules/shadowing/issue-19167-4-x.good create mode 100644 test/modules/shadowing/issue-19167-5-f.chpl create mode 100644 test/modules/shadowing/issue-19167-5-f.good create mode 100644 test/modules/shadowing/issue-19167-5-x.chpl create mode 100644 test/modules/shadowing/issue-19167-5-x.good create mode 100644 test/modules/shadowing/issue-19167-6-f.chpl create mode 100644 test/modules/shadowing/issue-19167-6-f.good create mode 100644 test/modules/shadowing/issue-19167-7-x.chpl create mode 100644 test/modules/shadowing/issue-19167-7-x.good diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 727f0d518165..23f99b5d8f49 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -1790,6 +1790,10 @@ Symbol* lookupAndCount(const char* name, nSymbolsFound = symbols.size(); + // if there were multiple symbols found, and some are last resort, + // and others are not, eliminate the last resort ones. + eliminateLastResortSyms(symbols); + if (symbols.size() == 0) { retval = NULL; @@ -2047,11 +2051,29 @@ static void lookupUseImport(const char* name, moduleUses = moduleUsesCache[block]; } + // after a NULL is found, the rest of the + // scopes are from a transitive use/import + bool foundNull = false; + + if (name == astr("exxy")) + gdbShouldBreakHere(); + forv_Vec(Stmt, stmt, *moduleUses) { + if (stmt == nullptr) { + printf("Found NULL\n"); + foundNull = true; + continue; + } + bool checkThisInShadowScope = false; - if (UseStmt* use = toUseStmt(stmt)) { - if (use->isPrivate) - checkThisInShadowScope = true; + if (foundNull) { + // all the scopes are transitive uses, so don't consider + // any shadow scopes. + } else { + if (UseStmt* use = toUseStmt(stmt)) { + if (use->isPrivate) + checkThisInShadowScope = true; + } } // Skip for now things that don't match the request @@ -2060,6 +2082,9 @@ static void lookupUseImport(const char* name, if (forShadowScope != checkThisInShadowScope) continue; + //if (name == astr("x") && context->getModule()->modTag == MOD_USER) + // gdbShouldBreakHere(); + if (UseStmt* use = toUseStmt(stmt)) { // Check to see if the module name matches what is use'd if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { @@ -2133,9 +2158,9 @@ static void lookupUseImport(const char* name, } } else { // break on each new depth if a symbol has been found - if (symbols.size() > 0) { - break; - } + //if (symbols.size() > 0) { + // break; + //} } } @@ -2158,6 +2183,8 @@ static void lookupUseImport(const char* name, } } } else { + // TODO: remove this block + // we haven't found a match yet, so as a last resort, let's // check the names of the modules in the 'use'/'import' statements // themselves... This effectively places the module names at @@ -2338,7 +2365,7 @@ static void buildBreadthFirstModuleList( Vec* modules, Vec* current, std::map >* alreadySeen) { - // use NULL as a sentinel to identify modules of equal depth + // use NULL as a sentinel to identify modules of equal depth modules->add(NULL); Vec next; diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index f6042575c950..02fba3fb9aa6 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -1860,9 +1860,15 @@ isDefinedInUseImport(BlockStmt* block, FnSymbol* fn, if (UseStmt* use = toUseStmt(expr)) { se = toSymExpr(use->src); isPrivate = use->isPrivate; + // TODO: handle renames + if (use->skipSymbolSearch(fn->name)) + continue; } else if (ImportStmt* imp = toImportStmt(expr)) { se = toSymExpr(imp->src); isPrivate = imp->isPrivate; + // TODO: handle renames + if (imp->skipSymbolSearch(fn->name)) + continue; } INT_ASSERT(se); diff --git a/test/modules/shadowing/issue-19167-1.chpl b/test/modules/shadowing/issue-19167-0.chpl similarity index 100% rename from test/modules/shadowing/issue-19167-1.chpl rename to test/modules/shadowing/issue-19167-0.chpl diff --git a/test/modules/shadowing/issue-19167-1.good b/test/modules/shadowing/issue-19167-0.good similarity index 100% rename from test/modules/shadowing/issue-19167-1.good rename to test/modules/shadowing/issue-19167-0.good diff --git a/test/modules/shadowing/issue-19167-1-f.chpl b/test/modules/shadowing/issue-19167-1-f.chpl new file mode 100644 index 000000000000..a752b2616819 --- /dev/null +++ b/test/modules/shadowing/issue-19167-1-f.chpl @@ -0,0 +1,47 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use UseA_UseB; // -> ambiguity between A.f and B.f + // -> x is multiply defined + + proc main() { + f(); + } +} diff --git a/test/modules/shadowing/issue-19167-1-f.good b/test/modules/shadowing/issue-19167-1-f.good new file mode 100644 index 000000000000..6c225e9e58e5 --- /dev/null +++ b/test/modules/shadowing/issue-19167-1-f.good @@ -0,0 +1,4 @@ +issue-19167-1-f.chpl:44: In function 'main': +issue-19167-1-f.chpl:45: error: ambiguous call 'f()' +issue-19167-1-f.chpl:2: note: candidates are: f() +issue-19167-1-f.chpl:6: note: f() diff --git a/test/modules/shadowing/issue-19167-1-x.chpl b/test/modules/shadowing/issue-19167-1-x.chpl new file mode 100644 index 000000000000..ef93181f005e --- /dev/null +++ b/test/modules/shadowing/issue-19167-1-x.chpl @@ -0,0 +1,47 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use UseA_UseB; // -> ambiguity between A.f and B.f + // -> x is multiply defined + + proc main() { + writeln(x); + } +} diff --git a/test/modules/shadowing/issue-19167-1-x.good b/test/modules/shadowing/issue-19167-1-x.good new file mode 100644 index 000000000000..fc6ab164b52d --- /dev/null +++ b/test/modules/shadowing/issue-19167-1-x.good @@ -0,0 +1,2 @@ +issue-19167-1-x.chpl:3: error: symbol x is multiply defined +issue-19167-1-x.chpl:7: note: also defined here diff --git a/test/modules/shadowing/issue-19167-2-f.chpl b/test/modules/shadowing/issue-19167-2-f.chpl new file mode 100644 index 000000000000..219d128fa83c --- /dev/null +++ b/test/modules/shadowing/issue-19167-2-f.chpl @@ -0,0 +1,47 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use UseA_UseUseB; // -> ambiguity between A.f and B.f + // -> x refers to A.x + + proc main() { + f(); + } +} diff --git a/test/modules/shadowing/issue-19167-2-f.good b/test/modules/shadowing/issue-19167-2-f.good new file mode 100644 index 000000000000..c198aa329297 --- /dev/null +++ b/test/modules/shadowing/issue-19167-2-f.good @@ -0,0 +1,4 @@ +issue-19167-2-f.chpl:44: In function 'main': +issue-19167-2-f.chpl:45: error: ambiguous call 'f()' +issue-19167-2-f.chpl:2: note: candidates are: f() +issue-19167-2-f.chpl:6: note: f() diff --git a/test/modules/shadowing/issue-19167-2-x.chpl b/test/modules/shadowing/issue-19167-2-x.chpl new file mode 100644 index 000000000000..a927d3f8aaed --- /dev/null +++ b/test/modules/shadowing/issue-19167-2-x.chpl @@ -0,0 +1,46 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use UseA_UseUseB; + + proc main() { + writeln(x); + } +} diff --git a/test/modules/shadowing/issue-19167-2-x.good b/test/modules/shadowing/issue-19167-2-x.good new file mode 100644 index 000000000000..f8f044ba9a9a --- /dev/null +++ b/test/modules/shadowing/issue-19167-2-x.good @@ -0,0 +1,2 @@ +issue-19167-2-x.chpl:3: error: symbol x is multiply defined +issue-19167-2-x.chpl:7: note: also defined here diff --git a/test/modules/shadowing/issue-19167-3-f.chpl b/test/modules/shadowing/issue-19167-3-f.chpl new file mode 100644 index 000000000000..275cb8414d68 --- /dev/null +++ b/test/modules/shadowing/issue-19167-3-f.chpl @@ -0,0 +1,47 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use CUseA; // -> f refers to C.f + // -> x refers to C.x + + proc main() { + f(); + } +} diff --git a/test/modules/shadowing/issue-19167-3-f.good b/test/modules/shadowing/issue-19167-3-f.good new file mode 100644 index 000000000000..df57140e821d --- /dev/null +++ b/test/modules/shadowing/issue-19167-3-f.good @@ -0,0 +1,4 @@ +issue-19167-3-f.chpl:44: In function 'main': +issue-19167-3-f.chpl:45: error: ambiguous call 'f()' +issue-19167-3-f.chpl:12: note: candidates are: f() +issue-19167-3-f.chpl:2: note: f() diff --git a/test/modules/shadowing/issue-19167-3-x.chpl b/test/modules/shadowing/issue-19167-3-x.chpl new file mode 100644 index 000000000000..70356f6253a0 --- /dev/null +++ b/test/modules/shadowing/issue-19167-3-x.chpl @@ -0,0 +1,47 @@ +module A { + proc f() { writeln("A.f"); } + var exxy = "A"; +} +module B { + proc f() { writeln("B.f"); } + var exxy = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var exxy = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use CUseA; // -> f refers to C.f + // -> x refers to C.x + + proc main() { + writeln(exxy); + } +} diff --git a/test/modules/shadowing/issue-19167-3-x.good b/test/modules/shadowing/issue-19167-3-x.good new file mode 100644 index 000000000000..2dd05e4e244b --- /dev/null +++ b/test/modules/shadowing/issue-19167-3-x.good @@ -0,0 +1 @@ +expecting ambiguity diff --git a/test/modules/shadowing/issue-19167-4-f.chpl b/test/modules/shadowing/issue-19167-4-f.chpl new file mode 100644 index 000000000000..aa99ca0abf14 --- /dev/null +++ b/test/modules/shadowing/issue-19167-4-f.chpl @@ -0,0 +1,47 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use CUseA_UseA; // -> ambiguity between A.f and C.f + // -> x is multiply defined + + proc main() { + f(); + } +} diff --git a/test/modules/shadowing/issue-19167-4-f.good b/test/modules/shadowing/issue-19167-4-f.good new file mode 100644 index 000000000000..fc4fcae05a5e --- /dev/null +++ b/test/modules/shadowing/issue-19167-4-f.good @@ -0,0 +1,4 @@ +issue-19167-4-f.chpl:44: In function 'main': +issue-19167-4-f.chpl:45: error: ambiguous call 'f()' +issue-19167-4-f.chpl:12: note: candidates are: f() +issue-19167-4-f.chpl:2: note: f() diff --git a/test/modules/shadowing/issue-19167-4-x.chpl b/test/modules/shadowing/issue-19167-4-x.chpl new file mode 100644 index 000000000000..4972bc58b9a4 --- /dev/null +++ b/test/modules/shadowing/issue-19167-4-x.chpl @@ -0,0 +1,47 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use CUseA_UseA; // -> ambiguity between A.f and C.f + // -> x is multiply defined + + proc main() { + writeln(x); + } +} diff --git a/test/modules/shadowing/issue-19167-4-x.good b/test/modules/shadowing/issue-19167-4-x.good new file mode 100644 index 000000000000..ccffe54c7d95 --- /dev/null +++ b/test/modules/shadowing/issue-19167-4-x.good @@ -0,0 +1,2 @@ +issue-19167-4-x.chpl:13: error: symbol x is multiply defined +issue-19167-4-x.chpl:3: note: also defined here diff --git a/test/modules/shadowing/issue-19167-5-f.chpl b/test/modules/shadowing/issue-19167-5-f.chpl new file mode 100644 index 000000000000..4aa03ed5bd42 --- /dev/null +++ b/test/modules/shadowing/issue-19167-5-f.chpl @@ -0,0 +1,46 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use CUseA_ImportA; // -> ambiguity between A.f and C.f + // -> x refers to C.x + proc main() { + f(); + } +} diff --git a/test/modules/shadowing/issue-19167-5-f.good b/test/modules/shadowing/issue-19167-5-f.good new file mode 100644 index 000000000000..93d309c459ec --- /dev/null +++ b/test/modules/shadowing/issue-19167-5-f.good @@ -0,0 +1,4 @@ +issue-19167-5-f.chpl:43: In function 'main': +issue-19167-5-f.chpl:44: error: ambiguous call 'f()' +issue-19167-5-f.chpl:12: note: candidates are: f() +issue-19167-5-f.chpl:2: note: f() diff --git a/test/modules/shadowing/issue-19167-5-x.chpl b/test/modules/shadowing/issue-19167-5-x.chpl new file mode 100644 index 000000000000..f7e601c3e527 --- /dev/null +++ b/test/modules/shadowing/issue-19167-5-x.chpl @@ -0,0 +1,46 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module CUseA_ImportA { + public use CUseA; + import A; +} + +module Program { + use CUseA_ImportA; // -> ambiguity between A.f and C.f + // -> x refers to C.x + proc main() { + writeln(x); + } +} diff --git a/test/modules/shadowing/issue-19167-5-x.good b/test/modules/shadowing/issue-19167-5-x.good new file mode 100644 index 000000000000..9bd9cd7de144 --- /dev/null +++ b/test/modules/shadowing/issue-19167-5-x.good @@ -0,0 +1,2 @@ +issue-19167-5-x.chpl:13: error: symbol x is multiply defined +issue-19167-5-x.chpl:3: note: also defined here diff --git a/test/modules/shadowing/issue-19167-6-f.chpl b/test/modules/shadowing/issue-19167-6-f.chpl new file mode 100644 index 000000000000..02b60c0a0e20 --- /dev/null +++ b/test/modules/shadowing/issue-19167-6-f.chpl @@ -0,0 +1,45 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module UseA_ImportB { + public use A; + import B; +} + +module Program { + use UseA_ImportB; + proc main() { + f(); + } +} diff --git a/test/modules/shadowing/issue-19167-6-f.good b/test/modules/shadowing/issue-19167-6-f.good new file mode 100644 index 000000000000..46d06e773c93 --- /dev/null +++ b/test/modules/shadowing/issue-19167-6-f.good @@ -0,0 +1 @@ +A.f diff --git a/test/modules/shadowing/issue-19167-7-x.chpl b/test/modules/shadowing/issue-19167-7-x.chpl new file mode 100644 index 000000000000..7d572dfcac36 --- /dev/null +++ b/test/modules/shadowing/issue-19167-7-x.chpl @@ -0,0 +1,45 @@ +module A { + proc f() { writeln("A.f"); } + var x = "A"; +} +module B { + proc f() { writeln("B.f"); } + var x = "B"; +} + +module CUseA { + public use A; + proc f() { writeln("C.f"); } + var x = "C"; +} + +module UseA_UseB { + public use A; + public use B; +} + +module UseB { + public use B; +} + +module UseA_UseUseB { + public use A; + public use UseB; +} + +module CUseA_UseA { + public use CUseA; + public use A; +} + +module UseA_ImportB { + public use A; + import B; +} + +module Program { + use UseA_ImportB; + proc main() { + writeln(x); + } +} diff --git a/test/modules/shadowing/issue-19167-7-x.good b/test/modules/shadowing/issue-19167-7-x.good new file mode 100644 index 000000000000..f70f10e4db19 --- /dev/null +++ b/test/modules/shadowing/issue-19167-7-x.good @@ -0,0 +1 @@ +A From dc9d12555746d384daade9d36b52ff2c875624e4 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 23 Feb 2022 14:57:12 -0500 Subject: [PATCH 06/96] Tidy up new tests --- Signed-off-by: Michael Ferguson --- test/modules/shadowing/issue-19167-0.chpl | 4 +-- test/modules/shadowing/issue-19167-1-f.chpl | 28 +------------------ test/modules/shadowing/issue-19167-1-f.good | 4 +-- test/modules/shadowing/issue-19167-1-x.chpl | 28 +------------------ test/modules/shadowing/issue-19167-2-f.chpl | 24 +--------------- test/modules/shadowing/issue-19167-2-f.good | 4 +-- test/modules/shadowing/issue-19167-2-x.chpl | 21 -------------- test/modules/shadowing/issue-19167-3-f.chpl | 31 +-------------------- test/modules/shadowing/issue-19167-3-f.good | 6 ++-- test/modules/shadowing/issue-19167-3-x.chpl | 31 +-------------------- test/modules/shadowing/issue-19167-4-f.chpl | 26 +---------------- test/modules/shadowing/issue-19167-4-f.good | 6 ++-- test/modules/shadowing/issue-19167-4-x.chpl | 26 +---------------- test/modules/shadowing/issue-19167-4-x.good | 2 +- test/modules/shadowing/issue-19167-5-f.chpl | 27 ++---------------- test/modules/shadowing/issue-19167-5-f.good | 6 ++-- test/modules/shadowing/issue-19167-5-x.chpl | 27 ++---------------- test/modules/shadowing/issue-19167-5-x.good | 2 +- test/modules/shadowing/issue-19167-6-f.chpl | 26 +---------------- test/modules/shadowing/issue-19167-7-x.chpl | 26 +---------------- 20 files changed, 30 insertions(+), 325 deletions(-) diff --git a/test/modules/shadowing/issue-19167-0.chpl b/test/modules/shadowing/issue-19167-0.chpl index 0ea90a70397a..baf240eba1a2 100644 --- a/test/modules/shadowing/issue-19167-0.chpl +++ b/test/modules/shadowing/issue-19167-0.chpl @@ -9,7 +9,7 @@ module N { proc main() { use M; - writeln(X); // prints out 0 so refers to M.X - f(); // ambiguity error + writeln(X); + f(); } } diff --git a/test/modules/shadowing/issue-19167-1-f.chpl b/test/modules/shadowing/issue-19167-1-f.chpl index a752b2616819..505a78d0f067 100644 --- a/test/modules/shadowing/issue-19167-1-f.chpl +++ b/test/modules/shadowing/issue-19167-1-f.chpl @@ -7,39 +7,13 @@ module B { var x = "B"; } -module CUseA { - public use A; - proc f() { writeln("C.f"); } - var x = "C"; -} - module UseA_UseB { public use A; public use B; } -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { - use UseA_UseB; // -> ambiguity between A.f and B.f - // -> x is multiply defined + use UseA_UseB; proc main() { f(); diff --git a/test/modules/shadowing/issue-19167-1-f.good b/test/modules/shadowing/issue-19167-1-f.good index 6c225e9e58e5..c65c80b607e7 100644 --- a/test/modules/shadowing/issue-19167-1-f.good +++ b/test/modules/shadowing/issue-19167-1-f.good @@ -1,4 +1,4 @@ -issue-19167-1-f.chpl:44: In function 'main': -issue-19167-1-f.chpl:45: error: ambiguous call 'f()' +issue-19167-1-f.chpl:18: In function 'main': +issue-19167-1-f.chpl:19: error: ambiguous call 'f()' issue-19167-1-f.chpl:2: note: candidates are: f() issue-19167-1-f.chpl:6: note: f() diff --git a/test/modules/shadowing/issue-19167-1-x.chpl b/test/modules/shadowing/issue-19167-1-x.chpl index ef93181f005e..2ff0c292682b 100644 --- a/test/modules/shadowing/issue-19167-1-x.chpl +++ b/test/modules/shadowing/issue-19167-1-x.chpl @@ -7,39 +7,13 @@ module B { var x = "B"; } -module CUseA { - public use A; - proc f() { writeln("C.f"); } - var x = "C"; -} - module UseA_UseB { public use A; public use B; } -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { - use UseA_UseB; // -> ambiguity between A.f and B.f - // -> x is multiply defined + use UseA_UseB; proc main() { writeln(x); diff --git a/test/modules/shadowing/issue-19167-2-f.chpl b/test/modules/shadowing/issue-19167-2-f.chpl index 219d128fa83c..46162ad6cc47 100644 --- a/test/modules/shadowing/issue-19167-2-f.chpl +++ b/test/modules/shadowing/issue-19167-2-f.chpl @@ -7,17 +7,6 @@ module B { var x = "B"; } -module CUseA { - public use A; - proc f() { writeln("C.f"); } - var x = "C"; -} - -module UseA_UseB { - public use A; - public use B; -} - module UseB { public use B; } @@ -27,19 +16,8 @@ module UseA_UseUseB { public use UseB; } -module CUseA_UseA { - public use CUseA; - public use A; -} - -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { - use UseA_UseUseB; // -> ambiguity between A.f and B.f - // -> x refers to A.x + use UseA_UseUseB; proc main() { f(); diff --git a/test/modules/shadowing/issue-19167-2-f.good b/test/modules/shadowing/issue-19167-2-f.good index c198aa329297..d85fb66c88bc 100644 --- a/test/modules/shadowing/issue-19167-2-f.good +++ b/test/modules/shadowing/issue-19167-2-f.good @@ -1,4 +1,4 @@ -issue-19167-2-f.chpl:44: In function 'main': -issue-19167-2-f.chpl:45: error: ambiguous call 'f()' +issue-19167-2-f.chpl:22: In function 'main': +issue-19167-2-f.chpl:23: error: ambiguous call 'f()' issue-19167-2-f.chpl:2: note: candidates are: f() issue-19167-2-f.chpl:6: note: f() diff --git a/test/modules/shadowing/issue-19167-2-x.chpl b/test/modules/shadowing/issue-19167-2-x.chpl index a927d3f8aaed..a4e68eb0dbc5 100644 --- a/test/modules/shadowing/issue-19167-2-x.chpl +++ b/test/modules/shadowing/issue-19167-2-x.chpl @@ -7,17 +7,6 @@ module B { var x = "B"; } -module CUseA { - public use A; - proc f() { writeln("C.f"); } - var x = "C"; -} - -module UseA_UseB { - public use A; - public use B; -} - module UseB { public use B; } @@ -27,16 +16,6 @@ module UseA_UseUseB { public use UseB; } -module CUseA_UseA { - public use CUseA; - public use A; -} - -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { use UseA_UseUseB; diff --git a/test/modules/shadowing/issue-19167-3-f.chpl b/test/modules/shadowing/issue-19167-3-f.chpl index 275cb8414d68..9e4a2f909506 100644 --- a/test/modules/shadowing/issue-19167-3-f.chpl +++ b/test/modules/shadowing/issue-19167-3-f.chpl @@ -2,10 +2,6 @@ module A { proc f() { writeln("A.f"); } var x = "A"; } -module B { - proc f() { writeln("B.f"); } - var x = "B"; -} module CUseA { public use A; @@ -13,33 +9,8 @@ module CUseA { var x = "C"; } -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { - use CUseA; // -> f refers to C.f - // -> x refers to C.x + use CUseA; proc main() { f(); diff --git a/test/modules/shadowing/issue-19167-3-f.good b/test/modules/shadowing/issue-19167-3-f.good index df57140e821d..99d7f7cf1926 100644 --- a/test/modules/shadowing/issue-19167-3-f.good +++ b/test/modules/shadowing/issue-19167-3-f.good @@ -1,4 +1,4 @@ -issue-19167-3-f.chpl:44: In function 'main': -issue-19167-3-f.chpl:45: error: ambiguous call 'f()' -issue-19167-3-f.chpl:12: note: candidates are: f() +issue-19167-3-f.chpl:15: In function 'main': +issue-19167-3-f.chpl:16: error: ambiguous call 'f()' +issue-19167-3-f.chpl:8: note: candidates are: f() issue-19167-3-f.chpl:2: note: f() diff --git a/test/modules/shadowing/issue-19167-3-x.chpl b/test/modules/shadowing/issue-19167-3-x.chpl index 70356f6253a0..176823398549 100644 --- a/test/modules/shadowing/issue-19167-3-x.chpl +++ b/test/modules/shadowing/issue-19167-3-x.chpl @@ -2,10 +2,6 @@ module A { proc f() { writeln("A.f"); } var exxy = "A"; } -module B { - proc f() { writeln("B.f"); } - var exxy = "B"; -} module CUseA { public use A; @@ -13,33 +9,8 @@ module CUseA { var exxy = "C"; } -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { - use CUseA; // -> f refers to C.f - // -> x refers to C.x + use CUseA; proc main() { writeln(exxy); diff --git a/test/modules/shadowing/issue-19167-4-f.chpl b/test/modules/shadowing/issue-19167-4-f.chpl index aa99ca0abf14..4b4ed8735d90 100644 --- a/test/modules/shadowing/issue-19167-4-f.chpl +++ b/test/modules/shadowing/issue-19167-4-f.chpl @@ -2,10 +2,6 @@ module A { proc f() { writeln("A.f"); } var x = "A"; } -module B { - proc f() { writeln("B.f"); } - var x = "B"; -} module CUseA { public use A; @@ -13,33 +9,13 @@ module CUseA { var x = "C"; } -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - module CUseA_UseA { public use CUseA; public use A; } -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { - use CUseA_UseA; // -> ambiguity between A.f and C.f - // -> x is multiply defined + use CUseA_UseA; proc main() { f(); diff --git a/test/modules/shadowing/issue-19167-4-f.good b/test/modules/shadowing/issue-19167-4-f.good index fc4fcae05a5e..1d98de8d41a8 100644 --- a/test/modules/shadowing/issue-19167-4-f.good +++ b/test/modules/shadowing/issue-19167-4-f.good @@ -1,4 +1,4 @@ -issue-19167-4-f.chpl:44: In function 'main': -issue-19167-4-f.chpl:45: error: ambiguous call 'f()' -issue-19167-4-f.chpl:12: note: candidates are: f() +issue-19167-4-f.chpl:20: In function 'main': +issue-19167-4-f.chpl:21: error: ambiguous call 'f()' +issue-19167-4-f.chpl:8: note: candidates are: f() issue-19167-4-f.chpl:2: note: f() diff --git a/test/modules/shadowing/issue-19167-4-x.chpl b/test/modules/shadowing/issue-19167-4-x.chpl index 4972bc58b9a4..e88d7eb8d7a8 100644 --- a/test/modules/shadowing/issue-19167-4-x.chpl +++ b/test/modules/shadowing/issue-19167-4-x.chpl @@ -2,10 +2,6 @@ module A { proc f() { writeln("A.f"); } var x = "A"; } -module B { - proc f() { writeln("B.f"); } - var x = "B"; -} module CUseA { public use A; @@ -13,33 +9,13 @@ module CUseA { var x = "C"; } -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - module CUseA_UseA { public use CUseA; public use A; } -module CUseA_ImportA { - public use CUseA; - import A; -} - module Program { - use CUseA_UseA; // -> ambiguity between A.f and C.f - // -> x is multiply defined + use CUseA_UseA; proc main() { writeln(x); diff --git a/test/modules/shadowing/issue-19167-4-x.good b/test/modules/shadowing/issue-19167-4-x.good index ccffe54c7d95..2c42cfa81fcb 100644 --- a/test/modules/shadowing/issue-19167-4-x.good +++ b/test/modules/shadowing/issue-19167-4-x.good @@ -1,2 +1,2 @@ -issue-19167-4-x.chpl:13: error: symbol x is multiply defined +issue-19167-4-x.chpl:9: error: symbol x is multiply defined issue-19167-4-x.chpl:3: note: also defined here diff --git a/test/modules/shadowing/issue-19167-5-f.chpl b/test/modules/shadowing/issue-19167-5-f.chpl index 4aa03ed5bd42..dfb5c9c96a6f 100644 --- a/test/modules/shadowing/issue-19167-5-f.chpl +++ b/test/modules/shadowing/issue-19167-5-f.chpl @@ -2,10 +2,6 @@ module A { proc f() { writeln("A.f"); } var x = "A"; } -module B { - proc f() { writeln("B.f"); } - var x = "B"; -} module CUseA { public use A; @@ -13,33 +9,14 @@ module CUseA { var x = "C"; } -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - module CUseA_ImportA { public use CUseA; import A; } module Program { - use CUseA_ImportA; // -> ambiguity between A.f and C.f - // -> x refers to C.x + use CUseA_ImportA; + proc main() { f(); } diff --git a/test/modules/shadowing/issue-19167-5-f.good b/test/modules/shadowing/issue-19167-5-f.good index 93d309c459ec..7516dcaa3eb0 100644 --- a/test/modules/shadowing/issue-19167-5-f.good +++ b/test/modules/shadowing/issue-19167-5-f.good @@ -1,4 +1,4 @@ -issue-19167-5-f.chpl:43: In function 'main': -issue-19167-5-f.chpl:44: error: ambiguous call 'f()' -issue-19167-5-f.chpl:12: note: candidates are: f() +issue-19167-5-f.chpl:20: In function 'main': +issue-19167-5-f.chpl:21: error: ambiguous call 'f()' +issue-19167-5-f.chpl:8: note: candidates are: f() issue-19167-5-f.chpl:2: note: f() diff --git a/test/modules/shadowing/issue-19167-5-x.chpl b/test/modules/shadowing/issue-19167-5-x.chpl index f7e601c3e527..6c278c1c65b7 100644 --- a/test/modules/shadowing/issue-19167-5-x.chpl +++ b/test/modules/shadowing/issue-19167-5-x.chpl @@ -2,10 +2,6 @@ module A { proc f() { writeln("A.f"); } var x = "A"; } -module B { - proc f() { writeln("B.f"); } - var x = "B"; -} module CUseA { public use A; @@ -13,33 +9,14 @@ module CUseA { var x = "C"; } -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - module CUseA_ImportA { public use CUseA; import A; } module Program { - use CUseA_ImportA; // -> ambiguity between A.f and C.f - // -> x refers to C.x + use CUseA_ImportA; + proc main() { writeln(x); } diff --git a/test/modules/shadowing/issue-19167-5-x.good b/test/modules/shadowing/issue-19167-5-x.good index 9bd9cd7de144..014409fbf89d 100644 --- a/test/modules/shadowing/issue-19167-5-x.good +++ b/test/modules/shadowing/issue-19167-5-x.good @@ -1,2 +1,2 @@ -issue-19167-5-x.chpl:13: error: symbol x is multiply defined +issue-19167-5-x.chpl:9: error: symbol x is multiply defined issue-19167-5-x.chpl:3: note: also defined here diff --git a/test/modules/shadowing/issue-19167-6-f.chpl b/test/modules/shadowing/issue-19167-6-f.chpl index 02b60c0a0e20..69169b8bc414 100644 --- a/test/modules/shadowing/issue-19167-6-f.chpl +++ b/test/modules/shadowing/issue-19167-6-f.chpl @@ -7,31 +7,6 @@ module B { var x = "B"; } -module CUseA { - public use A; - proc f() { writeln("C.f"); } - var x = "C"; -} - -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - module UseA_ImportB { public use A; import B; @@ -39,6 +14,7 @@ module UseA_ImportB { module Program { use UseA_ImportB; + proc main() { f(); } diff --git a/test/modules/shadowing/issue-19167-7-x.chpl b/test/modules/shadowing/issue-19167-7-x.chpl index 7d572dfcac36..791103c53f8a 100644 --- a/test/modules/shadowing/issue-19167-7-x.chpl +++ b/test/modules/shadowing/issue-19167-7-x.chpl @@ -7,31 +7,6 @@ module B { var x = "B"; } -module CUseA { - public use A; - proc f() { writeln("C.f"); } - var x = "C"; -} - -module UseA_UseB { - public use A; - public use B; -} - -module UseB { - public use B; -} - -module UseA_UseUseB { - public use A; - public use UseB; -} - -module CUseA_UseA { - public use CUseA; - public use A; -} - module UseA_ImportB { public use A; import B; @@ -39,6 +14,7 @@ module UseA_ImportB { module Program { use UseA_ImportB; + proc main() { writeln(x); } From e907b2d2c2cc53a67f78988ff6cc6be87a8f6548 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 23 Feb 2022 15:53:56 -0500 Subject: [PATCH 07/96] Fix test issue-19167-3-x --- Signed-off-by: Michael Ferguson --- compiler/AST/baseAST.cpp | 7 - compiler/include/scopeResolve.h | 2 - compiler/passes/scopeResolve.cpp | 425 +++----------------- test/modules/shadowing/issue-19167-3-x.chpl | 6 +- test/modules/shadowing/issue-19167-3-x.good | 3 +- 5 files changed, 62 insertions(+), 381 deletions(-) diff --git a/compiler/AST/baseAST.cpp b/compiler/AST/baseAST.cpp index 940e237c8bd2..3ebccbf13e20 100644 --- a/compiler/AST/baseAST.cpp +++ b/compiler/AST/baseAST.cpp @@ -242,13 +242,6 @@ void cleanAst() { serializeMap.erase(key); } - // Important: Sometimes scopeResolve will create dummy UseStmts that are - // never inserted into the tree, and will be deleted in between passes. - // - // If we do not destroy the caches, they may contain pointers back to these - // dummy uses. - destroyModuleUsesCaches(); - // // clear back pointers to dead ast instances // diff --git a/compiler/include/scopeResolve.h b/compiler/include/scopeResolve.h index cbf91983edae..4c298dd718b5 100644 --- a/compiler/include/scopeResolve.h +++ b/compiler/include/scopeResolve.h @@ -65,6 +65,4 @@ BaseAST* getScope(BaseAST* ast); void resolveUnresolvedSymExprs(BaseAST* ast); void resolveUnmanagedBorrows(CallExpr* call); -void destroyModuleUsesCaches(); - #endif diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 23f99b5d8f49..e136938237df 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -57,17 +57,6 @@ * * ************************************** | *************************************/ -// -// The moduleUsesCache is a cache from blocks with use-statements to -// the modules that they use arranged in breadth-first order and -// separated by NULL modules to indicate that the modules are not at -// the same depth. -// -// Note that this caching is not enabled until after use expression -// have been resolved. -// -static std::map*> moduleUsesCache; -static bool enableModuleUsesCache = false; // To avoid duplicate user warnings in checkIdInsideWithClause(). // Using pair<> instead of astlocT to avoid defining operator<. @@ -1629,17 +1618,6 @@ static void adjustTypeMethodsOnClasses() { } -void destroyModuleUsesCaches() { - std::map*>::iterator use; - - for (use = moduleUsesCache.begin(); use != moduleUsesCache.end(); use++) { - delete use->second; - } - - moduleUsesCache.clear(); -} - - static void renameDefaultType(Type* type, const char* newname); static void renameDefaultTypesToReflectWidths(void) { @@ -1947,18 +1925,6 @@ static bool methodMatched(BaseAST* scope, FnSymbol* method); static FnSymbol* getMethod(const char* name, Type* type); -static void buildBreadthFirstModuleList(Vec* modules); - -static void buildBreadthFirstModuleList( - Vec* modules, - Vec* current, - std::map >* alreadySeen); - -static bool skipUse(std::map >* seen, - UseStmt* current); -static bool skipUse(std::map >* seen, - ImportStmt* current); - static void lookupUseImport(const char* name, BaseAST* context, BaseAST* scope, @@ -1966,6 +1932,7 @@ static void lookupUseImport(const char* name, std::map& renameLocs, bool storeRenames, std::map& reexportPts, + std::set& visitedModules, bool forShadowScope); static @@ -1999,15 +1966,17 @@ bool lookupThisScopeAndUses(const char* name, symbols.push_back(sym); } + std::set visitedModules; + // check public use/imports lookupUseImport(name, context, scope, symbols, - renameLocs, storeRenames, reexportPts, + renameLocs, storeRenames, reexportPts, visitedModules, /* forShadowScope */ false); if (symbols.size() == 0) { // check private use only lookupUseImport(name, context, scope, symbols, - renameLocs, storeRenames, reexportPts, + renameLocs, storeRenames, reexportPts, visitedModules, /* forShadowScope */ true); } @@ -2021,58 +1990,37 @@ static void lookupUseImport(const char* name, std::map& renameLocs, bool storeRenames, std::map& reexportPts, + std::set& visitedModules, bool forShadowScope) { // Nothing found so far, look into the uses. if (BlockStmt* block = toBlockStmt(scope)) { if (block->useList != NULL) { - Vec* moduleUses = NULL; - - if (moduleUsesCache.count(block) == 0) { - moduleUses = new Vec(); - - for_actuals(expr, block->useList) { - // Ensure we only have use or import statements in this list - if (UseStmt* use = toUseStmt(expr)) { - moduleUses->add(use); - } else if (ImportStmt* import = toImportStmt(expr)) { - moduleUses->add(import); - } else { - INT_FATAL("Bad contents for useList, expected use or import"); - } + int nUseImport = 0; + for_actuals(expr, block->useList) { + // Ensure we only have use or import statements in this list + if (UseStmt* use = toUseStmt(expr)) { + INT_ASSERT(toSymExpr(use->src)); + // if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { + // if (mod->block->useList != NULL) { + nUseImport++; + } else if (ImportStmt* imp = toImportStmt(expr)) { + INT_ASSERT(toSymExpr(imp->src)); + nUseImport++; + } else { + INT_FATAL("Bad contents for useList, expected use or import"); } - - INT_ASSERT(moduleUses->n); - - buildBreadthFirstModuleList(moduleUses); - - if (enableModuleUsesCache) - moduleUsesCache[block] = moduleUses; - } else { - moduleUses = moduleUsesCache[block]; } - // after a NULL is found, the rest of the - // scopes are from a transitive use/import - bool foundNull = false; + INT_ASSERT(nUseImport > 0); if (name == astr("exxy")) gdbShouldBreakHere(); - forv_Vec(Stmt, stmt, *moduleUses) { - if (stmt == nullptr) { - printf("Found NULL\n"); - foundNull = true; - continue; - } - + for_actuals(stmt, block->useList) { bool checkThisInShadowScope = false; - if (foundNull) { - // all the scopes are transitive uses, so don't consider - // any shadow scopes. - } else { - if (UseStmt* use = toUseStmt(stmt)) { - if (use->isPrivate) - checkThisInShadowScope = true; + if (UseStmt* use = toUseStmt(stmt)) { + if (use->isPrivate) { + checkThisInShadowScope = true; } } @@ -2082,9 +2030,6 @@ static void lookupUseImport(const char* name, if (forShadowScope != checkThisInShadowScope) continue; - //if (name == astr("x") && context->getModule()->modTag == MOD_USER) - // gdbShouldBreakHere(); - if (UseStmt* use = toUseStmt(stmt)) { // Check to see if the module name matches what is use'd if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { @@ -2131,7 +2076,39 @@ static void lookupUseImport(const char* name, } } } + + // For a use statement, also look into public uses + // from whatever was used. + if (SymExpr* se = toSymExpr(use->src)) { + if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { + if (mod->block->useList != NULL) { + auto pair = visitedModules.insert(mod); + if (pair.second == false) { + // module has already been visited by this function + // so don't try to visit it again + } else { + lookupUseImport(name, context, mod->block, + symbols, renameLocs, storeRenames, + reexportPts, visitedModules, + /* forShadowScope */ false); + } + } + } + } + } else if (ImportStmt* import = toImportStmt(stmt)) { + // Check the name of the module + if (import->providesQualifiedAccess()) { + if (Symbol* modSym = import->checkIfModuleNameMatches(name)) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && import->isARename()) { + renameLocs[modSym] = &import->astloc; + } + } + } + } + // Only traverse import statements that define a symbol with this // name for unqualified access. We're only looking for explicitly // named symbols @@ -2157,10 +2134,7 @@ static void lookupUseImport(const char* name, } } } else { - // break on each new depth if a symbol has been found - //if (symbols.size() > 0) { - // break; - //} + INT_FATAL("should not be reachable"); } } @@ -2182,29 +2156,6 @@ static void lookupUseImport(const char* name, name); } } - } else { - // TODO: remove this block - - // we haven't found a match yet, so as a last resort, let's - // check the names of the modules in the 'use'/'import' statements - // themselves... This effectively places the module names at - // a scope just a bit further out than the one holding the - // symbols that they define. - forv_Vec(VisibilityStmt, stmt, *moduleUses) { - if (stmt != NULL) { - if (!isImportStmt(stmt) || - toImportStmt(stmt)->providesQualifiedAccess()) { - if (Symbol* modSym = stmt->checkIfModuleNameMatches(name)) { - if (isRepeat(modSym, symbols) == false) { - symbols.push_back(modSym); - if (storeRenames && stmt->isARename()) { - renameLocs[modSym] = &stmt->astloc; - } - } - } - } - } - } } } } @@ -2352,264 +2303,6 @@ static FnSymbol* getMethod(const char* name, Type* type) { return retval; } -static void buildBreadthFirstModuleList(Vec* modules) { - std::map > seen; - - return buildBreadthFirstModuleList(modules, modules, &seen); -} - -// If the uses of a particular module are considered its level 1 uses, then -// this function will only add level 2 and lower uses to the modules vector -// argument. -static void buildBreadthFirstModuleList( - Vec* modules, - Vec* current, - std::map >* alreadySeen) { - // use NULL as a sentinel to identify modules of equal depth - modules->add(NULL); - - Vec next; - - forv_expanding_Vec(VisibilityStmt, source, *current) { - if (!source) { - break; - } else { - if (UseStmt* srcUse = toUseStmt(source)) { - SymExpr* se = toSymExpr(srcUse->src); - INT_ASSERT(se); - if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { - if (mod->block->useList != NULL) { - for_actuals(expr, mod->block->useList) { - if (UseStmt* use = toUseStmt(expr)) { - SymExpr* useSE = toSymExpr(use->src); - INT_ASSERT(useSE); - - UseStmt* useToAdd = NULL; - if (!use->isPrivate && - !useSE->symbol()->hasFlag(FLAG_PRIVATE)) { - // Uses of private modules are not transitive - the symbols - // in the private modules are only visible to itself and its - // immediate parent. Therefore, if the symbol is private, - // we will not traverse it further and will merely add it to - // the alreadySeen map. - useToAdd = use->applyOuterUse(srcUse); - - if (useToAdd != NULL && - skipUse(alreadySeen, useToAdd) == false) { - next.add(useToAdd); - modules->add(useToAdd); - } - - // if applyOuterUse returned NULL, the number of symbols - // that could be provided from this use was 0, so it didn't - // need to be added to the alreadySeen map. - if (useToAdd != NULL) { - (*alreadySeen)[useSE->symbol()].push_back(useToAdd); - } - - } else if (!use->isPrivate && - useSE->symbol()->hasFlag(FLAG_PRIVATE)) { - // Private uses should be skipped, but should not prevent us - // from traversing the module in a later use of it, if that - // later use is not private. - (*alreadySeen)[useSE->symbol()].push_back(use); - } - } else if (ImportStmt* import = toImportStmt(expr)) { - SymExpr* importSE = toSymExpr(import->src); - INT_ASSERT(importSE); - - if (!import->isPrivate && - !importSE->symbol()->hasFlag(FLAG_PRIVATE)) { - ImportStmt* importToAdd = import->applyOuterUse(srcUse); - // Imports of private modules are not transitive - the - // symbols in the private modules are only visible to itself - // and its immediate parent. Therefore, if the symbol is - // private, we will not traverse it further and will merely - // add it to the alreadySeen map. - if (importToAdd != NULL && - skipUse(alreadySeen, importToAdd) == false) { - next.add(importToAdd); - modules->add(importToAdd); - } - - if (importToAdd != NULL) { - (*alreadySeen)[importSE->symbol()].push_back(importToAdd); - } - } else if (!import->isPrivate && - importSE->symbol()->hasFlag(FLAG_PRIVATE)) { - // If we're skipping because the import was public, but the - // module was private, then we shouldn't look at the module - // again and should add it to the alreadySeen map. Otherwise - // there might be a later import or use that is public, so - // we should allow it to be found - (*alreadySeen)[importSE->symbol()].push_back(import); - } - } else { - INT_ASSERT("Bad use list, expected UseStmt or ImportStmt"); - } - } - } - } - } else if (ImportStmt* srcImport = toImportStmt(source)) { - // Don't traverse the use statements of a module we imported for - // qualified access, their contents aren't brought into scope. - SymExpr* se = toSymExpr(srcImport->src); - INT_ASSERT(se); - ModuleSymbol* mod = toModuleSymbol(se->symbol()); - INT_ASSERT(mod); - if (mod->block->useList != NULL) { - for_actuals(expr, mod->block->useList) { - if (UseStmt* use = toUseStmt(expr)) { - SymExpr* useSE = toSymExpr(use->src); - INT_ASSERT(useSE); - - ImportStmt* importToAdd = NULL; - if (!use->isPrivate && - !useSE->symbol()->hasFlag(FLAG_PRIVATE)) { - // Uses of private modules are not transitive - the symbols - // in the private modules are only visible to itself and its - // immediate parent. Therefore, if the symbol is private, - // we will not traverse it further and will merely add it to - // the alreadySeen map. - importToAdd = use->applyOuterImport(srcImport); - - if (importToAdd != NULL && - skipUse(alreadySeen, importToAdd) == false) { - next.add(importToAdd); - modules->add(importToAdd); - } - - // if applyOuterUse returned NULL, the number of symbols - // that could be provided from this use was 0, so it didn't - // need to be added to the alreadySeen map. - if (importToAdd != NULL) { - (*alreadySeen)[useSE->symbol()].push_back(importToAdd); - } - - } else if (!use->isPrivate && - useSE->symbol()->hasFlag(FLAG_PRIVATE)) { - // Private uses should be skipped, but should not prevent us - // from traversing the module in a later use of it, if that - // later use is not private. - (*alreadySeen)[useSE->symbol()].push_back(use); - } - } else if (ImportStmt* import = toImportStmt(expr)) { - SymExpr* importSE = toSymExpr(import->src); - INT_ASSERT(importSE); - - if (!import->isPrivate && - !importSE->symbol()->hasFlag(FLAG_PRIVATE)) { - ImportStmt* importToAdd = import->applyOuterImport(srcImport); - // Imports of private modules are not transitive - the - // symbols in the private modules are only visible to itself - // and its immediate parent. Therefore, if the symbol is - // private, we will not traverse it further and will merely - // add it to the alreadySeen map. - if (importToAdd != NULL && - skipUse(alreadySeen, importToAdd) == false) { - next.add(importToAdd); - modules->add(importToAdd); - } - - if (importToAdd != NULL) { - (*alreadySeen)[importSE->symbol()].push_back(importToAdd); - } - } else if (!import->isPrivate && - importSE->symbol()->hasFlag(FLAG_PRIVATE)) { - // If we're skipping because the import was public, but the - // module was private, then we shouldn't look at the module - // again and should add it to the alreadySeen map. Otherwise - // there might be a later import or use that is public, so - // we should allow it to be found - (*alreadySeen)[importSE->symbol()].push_back(import); - } - } else { - INT_ASSERT("Bad use list, expected UseStmt or ImportStmt"); - } - } - } - - } else { - INT_ASSERT("Bad use list, expected UseStmt or ImportStmt"); - } - } - } - - if (next.n) { - buildBreadthFirstModuleList(modules, &next, alreadySeen); - } -} - -// Returns true if we should skip looking at this use, because the symbols it -// provides have already been covered by a previous use. -static bool skipUse(std::map >* seen, - UseStmt* current) { - SymExpr* useSE = toSymExpr(current->src); - - INT_ASSERT(useSE); - - std::vector vec = (*seen)[useSE->symbol()]; - - if (vec.size() > 0) { - // We've already seen at least one use of this module, but it might - // not be thorough enough to justify skipping the newest 'use'. - for_vector(VisibilityStmt, stmt, vec) { - if (UseStmt* use = toUseStmt(stmt)) { - if (current->providesNewSymbols(use) == false) { - // We found a prior use that covered all the symbols available - // from current. We can skip looking at current - return true; - } - } else if (ImportStmt* import = toImportStmt(stmt)) { - if (current->providesNewSymbols(import) == false) { - // The current use statement is equivalent to a prior import statement - // so no need to include it - return true; - } - } - } - } - - // We didn't have a prior use, or all the prior uses we missing at - // least one of the symbols current provides. Don't skip current. - return false; -} - -// Returns true if we should skip looking at this import, because the symbols it -// provides have already been covered by a previous use. -static bool skipUse(std::map >* seen, - ImportStmt* current) { - SymExpr* useSE = toSymExpr(current->src); - - INT_ASSERT(useSE); - - std::vector vec = (*seen)[useSE->symbol()]; - - if (vec.size() > 0) { - // We've already seen at least one use or import of this module, but it - // might not be thorough enough to justify skipping the newest 'import' - for_vector(VisibilityStmt, stmt, vec) { - if (UseStmt* use = toUseStmt(stmt)) { - if (current->providesNewSymbols(use) == false) { - // We found a prior use that covered all the symbols available - // from current. We can skip looking at current - return true; - } - } else if (ImportStmt* import = toImportStmt(stmt)) { - if (current->providesNewSymbols(import) == false) { - // The current import statement is equivalent to a prior import - // statement so no need to include it - return true; - } - } - } - } - - // We didn't have a prior use or import that covered the symbols this - // provides. Don't skip current. - return false; -} - /************************************* | ************************************** * * * Returns true if this module is capable of being used or traversed as part * @@ -3127,8 +2820,6 @@ void scopeResolve() { processImportExprs(); - enableModuleUsesCache = true; - computeClassHierarchy(); handleReceiverFormals(); @@ -3151,8 +2842,6 @@ void scopeResolve() { ResolveScope::destroyAstMap(); - destroyModuleUsesCaches(); - warnedForDotInsideWith.clear(); interfaceMethodNames.clear(); thisTypeToIfcFormal.clear(); diff --git a/test/modules/shadowing/issue-19167-3-x.chpl b/test/modules/shadowing/issue-19167-3-x.chpl index 176823398549..d86bec29d550 100644 --- a/test/modules/shadowing/issue-19167-3-x.chpl +++ b/test/modules/shadowing/issue-19167-3-x.chpl @@ -1,18 +1,18 @@ module A { proc f() { writeln("A.f"); } - var exxy = "A"; + var x = "A"; } module CUseA { public use A; proc f() { writeln("C.f"); } - var exxy = "C"; + var x = "C"; } module Program { use CUseA; proc main() { - writeln(exxy); + writeln(x); } } diff --git a/test/modules/shadowing/issue-19167-3-x.good b/test/modules/shadowing/issue-19167-3-x.good index 2dd05e4e244b..eba393184143 100644 --- a/test/modules/shadowing/issue-19167-3-x.good +++ b/test/modules/shadowing/issue-19167-3-x.good @@ -1 +1,2 @@ -expecting ambiguity +issue-19167-3-x.chpl:9: error: symbol x is multiply defined +issue-19167-3-x.chpl:3: note: also defined here From 8f853a05f6b56d70362bb68143ee0ec0a33b7a20 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 23 Feb 2022 16:25:15 -0500 Subject: [PATCH 08/96] Adjust modules primer --- Signed-off-by: Michael Ferguson --- test/release/examples/primers/modules.chpl | 18 ++++-------------- test/release/examples/primers/modules.good | 1 - 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/test/release/examples/primers/modules.chpl b/test/release/examples/primers/modules.chpl index 9f7e6faa4f65..fcddd408522e 100644 --- a/test/release/examples/primers/modules.chpl +++ b/test/release/examples/primers/modules.chpl @@ -264,8 +264,8 @@ module MainModule { // writeln(_.bar); // also an error, _ is not an identifier otherwise } - /* The symbols provided by a ``use`` statement are only considered when - the name in question cannot be resolved directly within the local + /* The symbols provided by a private ``use`` statement are only considered + when the name in question cannot be resolved directly within the local scope. Thus, because another ``bar`` is defined within this scope, the access to ``bar`` within the ``writeln`` will refer to the local variable ``bar`` rather than to ``modToUse.bar``. @@ -280,18 +280,8 @@ module MainModule { // '4.0'), rather than the value of modToUse.bar (which is '2') } - /* Again, the same is true of symbols provided by an ``import`` statement. - */ - { - var bar = 4.0; - - import modToUse.bar; - - writeln(bar); - // Will output the value of the bar defined in this scope (which is - // '4.0'), rather than the value of modToUse.bar (which is '2') - } - + /* In contrast, defining a symbol with the same name as something + imported leads to a multiple definition error. */ /* If a symbol cannot be resolved directly within the local scope, then the symbols provided by a ``use`` statement are considered before the diff --git a/test/release/examples/primers/modules.good b/test/release/examples/primers/modules.good index 3d4c5336206f..6bc57fc02612 100644 --- a/test/release/examples/primers/modules.good +++ b/test/release/examples/primers/modules.good @@ -29,7 +29,6 @@ Access from outside a module 2 2 4.0 -4.0 2 2 12 From cc7d1f93e04894260e1e0144e6796fd4b0ec1efd Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 23 Feb 2022 17:41:24 -0500 Subject: [PATCH 09/96] Allow private use to have 2 shadow scopes --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 104 ++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 24 deletions(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index e136938237df..fbce71cda301 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -1935,6 +1935,15 @@ static void lookupUseImport(const char* name, std::set& visitedModules, bool forShadowScope); +static void lookupUsedImportedMod(const char* name, + BaseAST* context, + BaseAST* scope, + std::vector& symbols, + std::map& renameLocs, + bool storeRenames, + bool forShadowScope); + + static bool lookupThisScopeAndUses(const char* name, BaseAST* context, @@ -1968,18 +1977,29 @@ bool lookupThisScopeAndUses(const char* name, std::set visitedModules; - // check public use/imports + // check imports and public use + // including names of modules imported or public use'd lookupUseImport(name, context, scope, symbols, renameLocs, storeRenames, reexportPts, visitedModules, /* forShadowScope */ false); if (symbols.size() == 0) { - // check private use only + // check private use only, not including names of modules + // (this forms the 1st shadow scope for a private use) lookupUseImport(name, context, scope, symbols, renameLocs, storeRenames, reexportPts, visitedModules, /* forShadowScope */ true); } + if (symbols.size() == 0) { + // Check to see if the module name matches what is use'd + // with a private use + // (this forms the 2nd shadow scope for a private use) + lookupUsedImportedMod(name, context, scope, symbols, + renameLocs, storeRenames, + /* forShadowScope */ true); + } + return symbols.size() != 0; } @@ -2016,6 +2036,13 @@ static void lookupUseImport(const char* name, if (name == astr("exxy")) gdbShouldBreakHere(); + if (forShadowScope == false) { + // check names of modules imported or public use'd + lookupUsedImportedMod(name, context, scope, symbols, + renameLocs, storeRenames, + /* forShadowScope */ false); + } + for_actuals(stmt, block->useList) { bool checkThisInShadowScope = false; if (UseStmt* use = toUseStmt(stmt)) { @@ -2031,16 +2058,6 @@ static void lookupUseImport(const char* name, continue; if (UseStmt* use = toUseStmt(stmt)) { - // Check to see if the module name matches what is use'd - if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { - if (isRepeat(modSym, symbols) == false) { - symbols.push_back(modSym); - if (storeRenames && use->isARename()) { - renameLocs[modSym] = &use->astloc; - } - } - } - if (use->skipSymbolSearch(name) == false) { const char* nameToUse = use->isARenamedSym(name) ? use->getRenamedSym(name) : name; @@ -2097,18 +2114,6 @@ static void lookupUseImport(const char* name, } } else if (ImportStmt* import = toImportStmt(stmt)) { - // Check the name of the module - if (import->providesQualifiedAccess()) { - if (Symbol* modSym = import->checkIfModuleNameMatches(name)) { - if (isRepeat(modSym, symbols) == false) { - symbols.push_back(modSym); - if (storeRenames && import->isARename()) { - renameLocs[modSym] = &import->astloc; - } - } - } - } - // Only traverse import statements that define a symbol with this // name for unqualified access. We're only looking for explicitly // named symbols @@ -2161,6 +2166,57 @@ static void lookupUseImport(const char* name, } } +static void lookupUsedImportedMod(const char* name, + BaseAST* context, + BaseAST* scope, + std::vector& symbols, + std::map& renameLocs, + bool storeRenames, + bool forShadowScope) { + // Check to see if the name matches a module name use'd / imported + if (BlockStmt* block = toBlockStmt(scope)) { + if (block->useList != NULL) { + for_actuals(stmt, block->useList) { + bool checkThisInShadowScope = false; + if (UseStmt* use = toUseStmt(stmt)) { + if (use->isPrivate) { + checkThisInShadowScope = true; + } + } + + // Skip for now things that don't match the request + // to find use/import for the shadow scope (or not). + // (these will be handled in a different call to this function) + if (forShadowScope != checkThisInShadowScope) + continue; + + if (UseStmt* use = toUseStmt(stmt)) { + if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && use->isARename()) { + renameLocs[modSym] = &use->astloc; + } + } + } + } else if (ImportStmt* imp = toImportStmt(stmt)) { + // Check the name of the module + if (imp->providesQualifiedAccess()) { + if (Symbol* modSym = imp->checkIfModuleNameMatches(name)) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && imp->isARename()) { + renameLocs[modSym] = &imp->astloc; + } + } + } + } + } + } + } + } +} + // Returns true if the symbol is present in the vector, false otherwise static bool isRepeat(Symbol* toAdd, const std::vector& symbols) { From 291d2ce40584c13a89cd4813a20883728617666c Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 09:58:29 -0500 Subject: [PATCH 10/96] Fix test_resolve_best_shadowed2 for different shadowing Changes it in to two tests to check both errors --- Signed-off-by: Michael Ferguson --- .../deitz/test_resolve_best_shadowed2.chpl | 19 +------------- .../deitz/test_resolve_best_shadowed2.good | 6 ++--- .../deitz/test_resolve_best_shadowed2b.chpl | 26 +++++++++++++++++++ .../deitz/test_resolve_best_shadowed2b.good | 4 +++ 4 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 test/functions/deitz/test_resolve_best_shadowed2b.chpl create mode 100644 test/functions/deitz/test_resolve_best_shadowed2b.good diff --git a/test/functions/deitz/test_resolve_best_shadowed2.chpl b/test/functions/deitz/test_resolve_best_shadowed2.chpl index 80bc5139b80a..8081d3267910 100644 --- a/test/functions/deitz/test_resolve_best_shadowed2.chpl +++ b/test/functions/deitz/test_resolve_best_shadowed2.chpl @@ -7,29 +7,12 @@ module OuterModule { } public use M2; - proc g() { } // shadows other g based on call to g + proc g() { } g(); - public use M3; - public use M4; - h(); } module M2 { proc g() { } } - - module M3 { - public use super.M5; - proc h() { } // does not shadow other h based on call to h since - // there is another path (through M4) to the other h - } - - module M4 { - public use super.M5; - } - - module M5 { - proc h() { } - } } diff --git a/test/functions/deitz/test_resolve_best_shadowed2.good b/test/functions/deitz/test_resolve_best_shadowed2.good index d75564b868df..9f3de49673dd 100644 --- a/test/functions/deitz/test_resolve_best_shadowed2.good +++ b/test/functions/deitz/test_resolve_best_shadowed2.good @@ -1,4 +1,4 @@ test_resolve_best_shadowed2.chpl:2: In function 'main': -test_resolve_best_shadowed2.chpl:15: error: ambiguous call 'h()' -test_resolve_best_shadowed2.chpl:24: note: candidates are: h() -test_resolve_best_shadowed2.chpl:33: note: h() +test_resolve_best_shadowed2.chpl:11: error: ambiguous call 'g()' +test_resolve_best_shadowed2.chpl:10: note: candidates are: g() +test_resolve_best_shadowed2.chpl:16: note: g() diff --git a/test/functions/deitz/test_resolve_best_shadowed2b.chpl b/test/functions/deitz/test_resolve_best_shadowed2b.chpl new file mode 100644 index 000000000000..d8c3bddbd8a4 --- /dev/null +++ b/test/functions/deitz/test_resolve_best_shadowed2b.chpl @@ -0,0 +1,26 @@ +module OuterModule { + proc main() { + proc f() { } + { + proc f() { } // shadows other f based on call to f + f(); + } + + public use M3; + public use M4; + h(); + } + + module M3 { + public use super.M5; + proc h() { } + } + + module M4 { + public use super.M5; + } + + module M5 { + proc h() { } + } +} diff --git a/test/functions/deitz/test_resolve_best_shadowed2b.good b/test/functions/deitz/test_resolve_best_shadowed2b.good new file mode 100644 index 000000000000..48fe49278017 --- /dev/null +++ b/test/functions/deitz/test_resolve_best_shadowed2b.good @@ -0,0 +1,4 @@ +test_resolve_best_shadowed2b.chpl:2: In function 'main': +test_resolve_best_shadowed2b.chpl:11: error: ambiguous call 'h()' +test_resolve_best_shadowed2b.chpl:16: note: candidates are: h() +test_resolve_best_shadowed2b.chpl:24: note: h() From c60407462f84065b0e7fd921f98b3c3fc9cffe4d Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 09:59:04 -0500 Subject: [PATCH 11/96] Fix apparently inadverdent use of Random --- Signed-off-by: Michael Ferguson --- test/constrained-generics/random/MyRandom.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/constrained-generics/random/MyRandom.chpl b/test/constrained-generics/random/MyRandom.chpl index 7ba06e7c15cc..f4f0eb9a2e45 100644 --- a/test/constrained-generics/random/MyRandom.chpl +++ b/test/constrained-generics/random/MyRandom.chpl @@ -764,7 +764,7 @@ module MyRandom { module PCGRandom { use super.RandomSupport; - private use Random, IO; + private use MyRandom, IO; private use PCGRandomLib; use ChapelLocks; From 8c994d963d41a2af913772f761b05941938c89ee Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 09:59:22 -0500 Subject: [PATCH 12/96] Use the POI scope to start isMoreVisible For functions/ferguson/hijacking/issue-18119-rev.chpl. The idea is that something can be more visible at the POI. Before PR #8079, we had isMoreVisible consult both regular scopes and POIs. However, after PR there is a candidate available without consulting POI. As a result, the candidates to be disambiguated must always come from a single POI. This commit adjusts the compiler to track the scope of that single POI and use it in isMoreVisible. --- Signed-off-by: Michael Ferguson --- compiler/include/resolution.h | 2 +- compiler/resolution/functionResolution.cpp | 56 +++++++++++++++------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/compiler/include/resolution.h b/compiler/include/resolution.h index ec3c931888f0..8c7795724e99 100644 --- a/compiler/include/resolution.h +++ b/compiler/include/resolution.h @@ -224,7 +224,7 @@ void explainAndCheckInstantiation(FnSymbol* newFn, FnSymbol* fn); class DisambiguationContext { public: - DisambiguationContext(CallInfo& info); + DisambiguationContext(CallInfo& info, BlockStmt* searchScope); Vec* actuals; Expr* scope; diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 02fba3fb9aa6..f5bd4f5573f8 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -1872,7 +1872,7 @@ isDefinedInUseImport(BlockStmt* block, FnSymbol* fn, } INT_ASSERT(se); - // Skip things that are private when considering a nested use/import + // Skip things that are private when considering a nested use/import if (isPrivate && !allowPrivateUseImp) continue; @@ -1896,12 +1896,12 @@ isDefinedInUseImport(BlockStmt* block, FnSymbol* fn, return false; } -static MoreVisibleResult +static MoreVisibleResult isMoreVisibleInternal(BlockStmt* block, FnSymbol* fn1, FnSymbol* fn2, Vec& visited1, Vec& visited2) { if (visited1.set_in(block) && visited2.set_in(block)) - return FOUND_NEITHER; + return FOUND_NEITHER; // first, check things in the current block or // from use/import that don't use a shadow scope @@ -1958,7 +1958,7 @@ isMoreVisibleInternal(BlockStmt* block, FnSymbol* fn1, FnSymbol* fn2, // // return whether fn1 is more visible than fn2 from expr // -static MoreVisibleResult +static MoreVisibleResult isMoreVisible(Expr* expr, FnSymbol* fn1, FnSymbol* fn2) { // // common-case check to see if functions have equal visibility @@ -3213,13 +3213,14 @@ static bool isGenericRecordInit(CallExpr* call); static FnSymbol* resolveNormalCall(CallInfo& info, check_state_t checkState); static FnSymbol* resolveNormalCall(CallExpr* call, check_state_t checkState); -static void findVisibleFunctionsAndCandidates( +static BlockStmt* findVisibleFunctionsAndCandidates( CallInfo& info, VisibilityInfo& visInfo, Vec& visibleFns, Vec& candidates); static int disambiguateByMatch(CallInfo& info, + BlockStmt* searchScope, Vec& candidates, ResolutionCandidate*& bestRef, ResolutionCandidate*& bestConstRef, @@ -3557,12 +3558,13 @@ static bool isAcceptableMethodChoice(CallExpr* call, } static void reportHijackingError(CallExpr* call, + BlockStmt* searchScope, FnSymbol* bestFn, ModuleSymbol* bestMod, FnSymbol* candFn, ModuleSymbol* candMod) { USR_FATAL_CONT(call, "multiple overload sets are applicable to this call"); - if (isMoreVisible(call, candFn, bestFn) == FOUND_F1_FIRST) + if (isMoreVisible(searchScope, candFn, bestFn) == FOUND_F1_FIRST) { USR_PRINT(candFn, "instead of the candidate here"); USR_PRINT(candMod, "... defined in this closer module"); @@ -3581,7 +3583,9 @@ static void reportHijackingError(CallExpr* call, USR_STOP(); } -static bool overloadSetsOK(CallExpr* call, check_state_t checkState, +static bool overloadSetsOK(CallExpr* call, + BlockStmt* searchScope, + check_state_t checkState, Vec& candidates, ResolutionCandidate* bestRef, ResolutionCandidate* bestCref, @@ -3622,11 +3626,12 @@ static bool overloadSetsOK(CallExpr* call, check_state_t checkState, ModuleSymbol* candMod = overloadSetModule(candidate); if (candMod && candMod != bestMod && - isMoreVisible(call, bestFn, candidate->fn) != FOUND_F1_FIRST && + isMoreVisible(searchScope, bestFn, candidate->fn) != FOUND_F1_FIRST && ! isAcceptableMethodChoice(call, bestFn, candidate->fn, candidates) ) { if (checkState == CHECK_NORMAL_CALL) - reportHijackingError(call, bestFn, bestMod, candidate->fn, candMod); + reportHijackingError(call, searchScope, + bestFn, bestMod, candidate->fn, candMod); return false; } } @@ -3652,9 +3657,12 @@ static FnSymbol* resolveNormalCall(CallInfo& info, check_state_t checkState) { FnSymbol* retval = NULL; - findVisibleFunctionsAndCandidates(info, visInfo, mostApplicable, candidates); + BlockStmt* scopeUsed = nullptr; - numMatches = disambiguateByMatch(info, candidates, + scopeUsed = findVisibleFunctionsAndCandidates(info, visInfo, + mostApplicable, candidates); + + numMatches = disambiguateByMatch(info, scopeUsed, candidates, bestRef, bestCref, bestVal); if (checkState == CHECK_NORMAL_CALL && numMatches > 0 && visInfo.inPOI()) @@ -3677,7 +3685,7 @@ static FnSymbol* resolveNormalCall(CallInfo& info, check_state_t checkState) { } if (numMatches > 0) { - if (! overloadSetsOK(info.call, checkState, candidates, + if (! overloadSetsOK(info.call, scopeUsed, checkState, candidates, bestRef, bestCref, bestVal)) return NULL; // overloadSetsOK() found an error @@ -4818,7 +4826,8 @@ void advanceCurrStart(VisibilityInfo& visInfo) { visInfo.nextPOI = NULL; } -static void findVisibleFunctionsAndCandidates( +// Returns the POI scope used to find the candidates +static BlockStmt* findVisibleFunctionsAndCandidates( CallInfo& info, VisibilityInfo& visInfo, Vec& mostApplicable, @@ -4838,7 +4847,7 @@ static void findVisibleFunctionsAndCandidates( explainGatherCandidate(info, candidates); - return; + return getVisibilityScope(call); } // CG TODO: pull all visible interface functions, if within a CG context @@ -4852,6 +4861,7 @@ static void findVisibleFunctionsAndCandidates( std::set visited; visInfo.currStart = getVisibilityScope(call); INT_ASSERT(visInfo.poiDepth == -1); // we have not used it + BlockStmt* scopeUsed = nullptr; do { // CG TODO: no POI for CG functions @@ -4866,6 +4876,9 @@ static void findVisibleFunctionsAndCandidates( gatherCandidatesAndLastResort(info, visInfo, mostApplicable, numVisitedMA, lrc, candidates); + // save the scope used for disambiguation + scopeUsed = visInfo.currStart; + advanceCurrStart(visInfo); } while @@ -4885,6 +4898,8 @@ static void findVisibleFunctionsAndCandidates( } explainGatherCandidate(info, candidates); + + return scopeUsed; } // run filterCandidate() on 'fn' if appropriate @@ -5288,19 +5303,22 @@ static void testOpArgMapping(FnSymbol* fn1, ArgSymbol* formal1, FnSymbol* fn2, ResolutionCandidate* disambiguateForInit(CallInfo& info, Vec& candidates) { - DisambiguationContext DC(info); + DisambiguationContext DC(info, getVisibilityScope(info.call)); Vec ambiguous; return disambiguateByMatch(candidates, DC, false, ambiguous); } + +// searchScope is the scope used to evaluate is-more-visible static int disambiguateByMatch(CallInfo& info, + BlockStmt* searchScope, Vec& candidates, ResolutionCandidate*& bestRef, ResolutionCandidate*& bestConstRef, ResolutionCandidate*& bestValue) { - DisambiguationContext DC(info); + DisambiguationContext DC(info, searchScope); Vec ambiguous; @@ -12026,9 +12044,11 @@ void expandInitFieldPrims() * * ************************************** | *************************************/ -DisambiguationContext::DisambiguationContext(CallInfo& info) { +DisambiguationContext::DisambiguationContext(CallInfo& info, + BlockStmt* searchScope) { actuals = &info.actuals; - scope = (info.scope) ? info.scope : getVisibilityScope(info.call); + scope = searchScope; + explain = false; if (fExplainVerbose == true) { From 37d9a23e79a7cca3691f575a261eefabfd1c9adb Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:08:28 -0500 Subject: [PATCH 13/96] Add test from issue #19198 --- Signed-off-by: Michael Ferguson --- test/functions/generic/poi/issue-19198.chpl | 29 +++++++++++++++++++++ test/functions/generic/poi/issue-19198.good | 6 +++++ 2 files changed, 35 insertions(+) create mode 100644 test/functions/generic/poi/issue-19198.chpl create mode 100644 test/functions/generic/poi/issue-19198.good diff --git a/test/functions/generic/poi/issue-19198.chpl b/test/functions/generic/poi/issue-19198.chpl new file mode 100644 index 000000000000..b6ab5b973522 --- /dev/null +++ b/test/functions/generic/poi/issue-19198.chpl @@ -0,0 +1,29 @@ +module G { + proc genericfunc(param p) { + helper1(); + } +} + +module M { + use G; + proc mCallFunc() { + writeln("mCallFunc"); + genericfunc(1); + } + proc helper1() { writeln("M.helper1"); } +} + +module N { + use G,M; + proc helper1() { writeln("N.helper1"); } + proc helper1() { writeln("N.helper1 mark two"); } + proc nCallFunc() { + writeln("nCallFunc"); + genericfunc(1); + } + + proc main() { + nCallFunc(); + mCallFunc(); + } +} diff --git a/test/functions/generic/poi/issue-19198.good b/test/functions/generic/poi/issue-19198.good new file mode 100644 index 000000000000..6519e29e1628 --- /dev/null +++ b/test/functions/generic/poi/issue-19198.good @@ -0,0 +1,6 @@ +issue-19198.chpl:2: In function 'genericfunc': +issue-19198.chpl:3: error: ambiguous call 'helper1()' +issue-19198.chpl:18: note: candidates are: helper1() +issue-19198.chpl:19: note: helper1() +issue-19198.chpl:13: note: helper1() + issue-19198.chpl:22: called as genericfunc(param p = 1) From 551d0faff1211aa90fbb45a891c8f8bffef3dead Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:23:36 -0500 Subject: [PATCH 14/96] Update some module scoping tests --- Signed-off-by: Michael Ferguson --- test/modules/diten/testIfModuleShadowsLocal.good | 1 + test/modules/diten/test_use_chain_resolution.chpl | 2 +- test/modules/diten/test_use_chain_resolution.good | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/modules/diten/testIfModuleShadowsLocal.good b/test/modules/diten/testIfModuleShadowsLocal.good index ca67c99eda7b..6bc2a4cc6a9c 100644 --- a/test/modules/diten/testIfModuleShadowsLocal.good +++ b/test/modules/diten/testIfModuleShadowsLocal.good @@ -1 +1,2 @@ +testIfModuleShadowsLocal.chpl:9: warning: Module level symbol is hiding function argument 'a' 1.0 + 2.0i diff --git a/test/modules/diten/test_use_chain_resolution.chpl b/test/modules/diten/test_use_chain_resolution.chpl index 5e008da9d641..6dacabe0c8bc 100644 --- a/test/modules/diten/test_use_chain_resolution.chpl +++ b/test/modules/diten/test_use_chain_resolution.chpl @@ -22,6 +22,6 @@ module M6 { var aaa = 6; proc main() { public use M3, M5; - writeln(aaa); // Expect 54 + writeln(aaa); } } diff --git a/test/modules/diten/test_use_chain_resolution.good b/test/modules/diten/test_use_chain_resolution.good index fb1e7bc86996..f6686a75f4ff 100644 --- a/test/modules/diten/test_use_chain_resolution.good +++ b/test/modules/diten/test_use_chain_resolution.good @@ -1 +1,2 @@ -54 +test_use_chain_resolution.chpl:2: error: symbol aaa is multiply defined +test_use_chain_resolution.chpl:14: note: also defined here From f942a9accfdbb3f6a0ee2a5f7a7532974562f779 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:35:43 -0500 Subject: [PATCH 15/96] Use private use rather than public use --- Signed-off-by: Michael Ferguson --- .../fully_blocked/elemental_cholesky_fully_blocked.chpl | 2 +- .../fully_blocked/test_fully_blocked_elemental_cholesky.chpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/elemental_cholesky_fully_blocked.chpl b/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/elemental_cholesky_fully_blocked.chpl index 3659a4dab2cb..09e6c8445f7b 100644 --- a/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/elemental_cholesky_fully_blocked.chpl +++ b/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/elemental_cholesky_fully_blocked.chpl @@ -69,7 +69,7 @@ module elemental_cholesky_fully_blocked { use CyclicDist, Barriers; - public use blocked_elemental_schur_complement, + use blocked_elemental_schur_complement, locality_info, local_reduced_matrix_cyclic_partition_fb, scalar_inner_product_cholesky, diff --git a/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/test_fully_blocked_elemental_cholesky.chpl b/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/test_fully_blocked_elemental_cholesky.chpl index 180f6fa0cf58..c5d6a4e8bf4b 100644 --- a/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/test_fully_blocked_elemental_cholesky.chpl +++ b/test/studies/cholesky/jglewis/version2/elemental/fully_blocked/test_fully_blocked_elemental_cholesky.chpl @@ -13,7 +13,7 @@ module test_fully_blocked_elemental_cholesky { use cholesky_execution_config_consts; - public use elemental_cholesky_fully_blocked; + use elemental_cholesky_fully_blocked; proc main { From 8a604618d8a5bb1b5224a6900b90e0b8c5699475 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:48:58 -0500 Subject: [PATCH 16/96] Use 'pe' rather than 'e' to avoid conflicts with Math.e --- Signed-off-by: Michael Ferguson --- test/types/string/sungeun/c_string/casts.chpl | 2 +- test/types/string/sungeun/c_string/concat.chpl | 6 +++--- test/types/string/sungeun/c_string/decls.chpl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/types/string/sungeun/c_string/casts.chpl b/test/types/string/sungeun/c_string/casts.chpl index eceaae84d566..56cc54671e66 100644 --- a/test/types/string/sungeun/c_string/casts.chpl +++ b/test/types/string/sungeun/c_string/casts.chpl @@ -48,5 +48,5 @@ writeln(n:string); writeln(r:string); writeln(i:string); writeln(c:string); -writeln(e:string); +writeln(pe:string); writeln(b:string); diff --git a/test/types/string/sungeun/c_string/concat.chpl b/test/types/string/sungeun/c_string/concat.chpl index 5f8c0f0ac1a3..8641e83184d5 100644 --- a/test/types/string/sungeun/c_string/concat.chpl +++ b/test/types/string/sungeun/c_string/concat.chpl @@ -30,9 +30,9 @@ checkType(string, ("8"+c:string).type); // no param complex checkType(string, (createStringWithNewBuffer(cstr)+c:string).type); checkType(string, (createStringWithNewBuffer(vcstr)+c:string).type); -checkType(string, (c"8"+e:string).type); -checkType(string, ("8"+e:string).type); -checkType(string, (cstr+e:string).type); +checkType(string, (c"8"+pe:string).type); +checkType(string, ("8"+pe:string).type); +checkType(string, (cstr+pe:string).type); checkType(string, (createStringWithNewBuffer(vcstr)+e:string).type); checkType(string, ("8"+ee:string).type); checkType(string, (createStringWithNewBuffer(cstr)+ee:string).type); diff --git a/test/types/string/sungeun/c_string/decls.chpl b/test/types/string/sungeun/c_string/decls.chpl index 66efb4e6f341..fd223bde7d37 100644 --- a/test/types/string/sungeun/c_string/decls.chpl +++ b/test/types/string/sungeun/c_string/decls.chpl @@ -25,7 +25,7 @@ const rr = r; param i = 4.0i; const ii = i; const c:complex = 4.0+4.0i; -param e = E.two; +param pe = E.two; const ee = e; param b = true; const bb = b; From d8e3e35fbc859f581f76b1ca14fb9b9bf3ec6b4b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:51:13 -0500 Subject: [PATCH 17/96] Rename module with same name as class --- Signed-off-by: Michael Ferguson --- test/performance/thomasvandoren/TestHelpers.chpl | 6 +++--- .../thomasvandoren/{counts.chpl => CountsMod.chpl} | 0 .../thomasvandoren/{counts.notest => CountsMod.notest} | 0 test/reductions/thomasvandoren/scanCountsInherit.chpl | 2 +- test/reductions/thomasvandoren/test/TestCounts.chpl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename test/reductions/thomasvandoren/{counts.chpl => CountsMod.chpl} (100%) rename test/reductions/thomasvandoren/{counts.notest => CountsMod.notest} (100%) diff --git a/test/performance/thomasvandoren/TestHelpers.chpl b/test/performance/thomasvandoren/TestHelpers.chpl index 0b8b81465c32..452aeb254bd2 100644 --- a/test/performance/thomasvandoren/TestHelpers.chpl +++ b/test/performance/thomasvandoren/TestHelpers.chpl @@ -27,11 +27,11 @@ var A: [outerRows, inner] int, C: [outerRows, outerCols] int; // Fill A and B with random values. -fillRandom(A); -fillRandom(B); +myFillRandom(A); +myFillRandom(B); /* Fill int array with random values. */ -proc fillRandom(ref A: [] int) { +proc myFillRandom(ref A: [] int) { // Use serial loop so A filling is reproducible when seed is same. for a in A { a = (randStream.getNext() * A.size): int; diff --git a/test/reductions/thomasvandoren/counts.chpl b/test/reductions/thomasvandoren/CountsMod.chpl similarity index 100% rename from test/reductions/thomasvandoren/counts.chpl rename to test/reductions/thomasvandoren/CountsMod.chpl diff --git a/test/reductions/thomasvandoren/counts.notest b/test/reductions/thomasvandoren/CountsMod.notest similarity index 100% rename from test/reductions/thomasvandoren/counts.notest rename to test/reductions/thomasvandoren/CountsMod.notest diff --git a/test/reductions/thomasvandoren/scanCountsInherit.chpl b/test/reductions/thomasvandoren/scanCountsInherit.chpl index 132b55346ede..0b3a287d09a6 100644 --- a/test/reductions/thomasvandoren/scanCountsInherit.chpl +++ b/test/reductions/thomasvandoren/scanCountsInherit.chpl @@ -8,7 +8,7 @@ * could determine a ranking of the particles within each octant. */ -public use counts; +public use CountsMod; class scanCountsInherit : counts { // Track the current value, so it can be used in generate() method. Use min() diff --git a/test/reductions/thomasvandoren/test/TestCounts.chpl b/test/reductions/thomasvandoren/test/TestCounts.chpl index caf90f2de2e5..034bfa5afc39 100644 --- a/test/reductions/thomasvandoren/test/TestCounts.chpl +++ b/test/reductions/thomasvandoren/test/TestCounts.chpl @@ -2,7 +2,7 @@ * Verify user defined counts reduction works with defaults. */ -use counts; +use CountsMod; var particles = [6, 7, 6, 3, 8, 2, 8, 4, 8, 3], octantCounts = counts reduce particles; From f06629a8d4bf4ae7fe9fe6b0d41cdf528ec4dc9f Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:51:41 -0500 Subject: [PATCH 18/96] Update a spec test for new behavior Note: will have to update the spec description still --- Signed-off-by: Michael Ferguson --- doc/rst/language/spec/modules.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/rst/language/spec/modules.rst b/doc/rst/language/spec/modules.rst index aba59bef0e85..8f6254f97976 100644 --- a/doc/rst/language/spec/modules.rst +++ b/doc/rst/language/spec/modules.rst @@ -394,7 +394,8 @@ necessary to obtain them. For instance, .. code-block:: printoutput - false + conflict1.chpl:2: error: symbol x is multiply defined + conflict1.chpl:10: note: also defined here If, however, C had been publicly used by another module D and that was used by MainMod instead, then the compiler cannot determine which of ``C.x`` and From 39127a3d739dd9797d24c51b26fc0ee00abf2086 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:52:05 -0500 Subject: [PATCH 19/96] Avoid conflict with Math.e by moving use --- Signed-off-by: Michael Ferguson --- test/types/enum/lydia/use/useMultiple.chpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/types/enum/lydia/use/useMultiple.chpl b/test/types/enum/lydia/use/useMultiple.chpl index 5c2f3d8da328..b1cd81c0408c 100644 --- a/test/types/enum/lydia/use/useMultiple.chpl +++ b/test/types/enum/lydia/use/useMultiple.chpl @@ -5,9 +5,8 @@ module M { enum bar {d, e, f}; - use foo, bar; - proc main() { + use foo, bar; writeln(a, " ", b, " ", c); writeln(d, " ", e, " ", f); } From cc1afb37fcedc40520e5b9167a4fe7f071219637 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:52:20 -0500 Subject: [PATCH 20/96] Update test for back to 2 shadow scopes for private use --- Signed-off-by: Michael Ferguson --- test/modules/use/issue-19219.good | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/modules/use/issue-19219.good b/test/modules/use/issue-19219.good index bbb89e7218c4..573541ac9702 100644 --- a/test/modules/use/issue-19219.good +++ b/test/modules/use/issue-19219.good @@ -1,2 +1 @@ -issue-19219.chpl:1: error: symbol M is multiply defined -issue-19219.chpl:2: note: also defined here +0 From 8c774b833e45f294db7b9ebc3ace05d7cdbd4b01 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 10:52:49 -0500 Subject: [PATCH 21/96] Update breakList.good for new behavior It goes from a multiple overload sets error to running and printing "I Got you!". That is because the LibGL shadow scope is closer than the LinkedLists shadow scope. I think this had the previous behavior only due to bugs in isMoreVisible in function resolution. --- Signed-off-by: Michael Ferguson --- test/classes/diten/breakList.good | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/classes/diten/breakList.good b/test/classes/diten/breakList.good index 2d18c58c117b..3caa3f510058 100644 --- a/test/classes/diten/breakList.good +++ b/test/classes/diten/breakList.good @@ -1,7 +1,2 @@ -breakList.chpl:23: In function 'bar': -breakList.chpl:26: error: multiple overload sets are applicable to this call -breakList.chpl:6: note: the best-matching candidate is here -breakList.chpl:3: note: ... defined in this module -$CHPL_HOME/modules/packages/LinkedLists.chpl:nnnn: note: even though the candidate here is also available -$CHPL_HOME/modules/packages/LinkedLists.chpl:nnnn: note: ... defined in this module -breakList.chpl:26: note: use --no-overload-sets-checks to disable overload sets errors +3.0 4.0 +breakList.chpl:7: error: halt reached - I Got you! From f628a0e5134e6e269eda620d87473e06085e877e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 11:15:26 -0500 Subject: [PATCH 22/96] Fix except handling --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 35 ++++++++++++++------------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index fbce71cda301..063d0b544ba4 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -2020,8 +2020,6 @@ static void lookupUseImport(const char* name, // Ensure we only have use or import statements in this list if (UseStmt* use = toUseStmt(expr)) { INT_ASSERT(toSymExpr(use->src)); - // if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { - // if (mod->block->useList != NULL) { nUseImport++; } else if (ImportStmt* imp = toImportStmt(expr)) { INT_ASSERT(toSymExpr(imp->src)); @@ -2033,9 +2031,6 @@ static void lookupUseImport(const char* name, INT_ASSERT(nUseImport > 0); - if (name == astr("exxy")) - gdbShouldBreakHere(); - if (forShadowScope == false) { // check names of modules imported or public use'd lookupUsedImportedMod(name, context, scope, symbols, @@ -2092,22 +2087,22 @@ static void lookupUseImport(const char* name, } } } - } - // For a use statement, also look into public uses - // from whatever was used. - if (SymExpr* se = toSymExpr(use->src)) { - if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { - if (mod->block->useList != NULL) { - auto pair = visitedModules.insert(mod); - if (pair.second == false) { - // module has already been visited by this function - // so don't try to visit it again - } else { - lookupUseImport(name, context, mod->block, - symbols, renameLocs, storeRenames, - reexportPts, visitedModules, - /* forShadowScope */ false); + // For a use statement, also look into public uses + // from whatever was used. + if (SymExpr* se = toSymExpr(use->src)) { + if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { + if (mod->block->useList != NULL) { + auto pair = visitedModules.insert(mod); + if (pair.second == false) { + // module has already been visited by this function + // so don't try to visit it again + } else { + lookupUseImport(nameToUse, context, mod->block, + symbols, renameLocs, storeRenames, + reexportPts, visitedModules, + /* forShadowScope */ false); + } } } } From 6b990c1ef3eba492bd150ffa46868c8612f6b651 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 11:23:18 -0500 Subject: [PATCH 23/96] Check in nested public imports & track publicOnly --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 69 +++++++++++++++---- .../except/deepUseWouldConflict.chpl | 2 +- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 063d0b544ba4..b6b9ad903606 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -1933,7 +1933,8 @@ static void lookupUseImport(const char* name, bool storeRenames, std::map& reexportPts, std::set& visitedModules, - bool forShadowScope); + bool forShadowScope, + bool publicOnly); static void lookupUsedImportedMod(const char* name, BaseAST* context, @@ -1941,7 +1942,8 @@ static void lookupUsedImportedMod(const char* name, std::vector& symbols, std::map& renameLocs, bool storeRenames, - bool forShadowScope); + bool forShadowScope, + bool publicOnly); static @@ -1981,14 +1983,16 @@ bool lookupThisScopeAndUses(const char* name, // including names of modules imported or public use'd lookupUseImport(name, context, scope, symbols, renameLocs, storeRenames, reexportPts, visitedModules, - /* forShadowScope */ false); + /* forShadowScope */ false, + /* publicOnly */ false); if (symbols.size() == 0) { // check private use only, not including names of modules // (this forms the 1st shadow scope for a private use) lookupUseImport(name, context, scope, symbols, renameLocs, storeRenames, reexportPts, visitedModules, - /* forShadowScope */ true); + /* forShadowScope */ true, + /* publicOnly */ false); } if (symbols.size() == 0) { @@ -1997,7 +2001,8 @@ bool lookupThisScopeAndUses(const char* name, // (this forms the 2nd shadow scope for a private use) lookupUsedImportedMod(name, context, scope, symbols, renameLocs, storeRenames, - /* forShadowScope */ true); + /* forShadowScope */ true, + /* publicOnly */ false); } return symbols.size() != 0; @@ -2011,7 +2016,8 @@ static void lookupUseImport(const char* name, bool storeRenames, std::map& reexportPts, std::set& visitedModules, - bool forShadowScope) { + bool forShadowScope, + bool publicOnly) { // Nothing found so far, look into the uses. if (BlockStmt* block = toBlockStmt(scope)) { if (block->useList != NULL) { @@ -2035,15 +2041,18 @@ static void lookupUseImport(const char* name, // check names of modules imported or public use'd lookupUsedImportedMod(name, context, scope, symbols, renameLocs, storeRenames, - /* forShadowScope */ false); + /* forShadowScope */ false, + /* publicOnly */ publicOnly); } for_actuals(stmt, block->useList) { + bool isPublic = false; bool checkThisInShadowScope = false; if (UseStmt* use = toUseStmt(stmt)) { - if (use->isPrivate) { - checkThisInShadowScope = true; - } + isPublic = !use->isPrivate; + checkThisInShadowScope = use->isPrivate; + } else if (ImportStmt* imp = toImportStmt(stmt)) { + isPublic = !imp->isPrivate; } // Skip for now things that don't match the request @@ -2052,6 +2061,9 @@ static void lookupUseImport(const char* name, if (forShadowScope != checkThisInShadowScope) continue; + if (publicOnly && !isPublic) + continue; + if (UseStmt* use = toUseStmt(stmt)) { if (use->skipSymbolSearch(name) == false) { const char* nameToUse = use->isARenamedSym(name) ? @@ -2101,7 +2113,8 @@ static void lookupUseImport(const char* name, lookupUseImport(nameToUse, context, mod->block, symbols, renameLocs, storeRenames, reexportPts, visitedModules, - /* forShadowScope */ false); + /* forShadowScope */ false, + /* publicOnly */ true); } } } @@ -2132,6 +2145,26 @@ static void lookupUseImport(const char* name, } } } + + // also check to see if the module imported has the + // symbol, recursively + if (SymExpr* se = toSymExpr(import->src)) { + if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { + if (mod->block->useList != NULL) { + auto pair = visitedModules.insert(mod); + if (pair.second == false) { + // module has already been visited by this function + // so don't try to visit it again + } else { + lookupUseImport(nameToUse, context, mod->block, + symbols, renameLocs, storeRenames, + reexportPts, visitedModules, + /* forShadowScope */ false, + /* publicOnly */ true); + } + } + } + } } } else { INT_FATAL("should not be reachable"); @@ -2167,16 +2200,19 @@ static void lookupUsedImportedMod(const char* name, std::vector& symbols, std::map& renameLocs, bool storeRenames, - bool forShadowScope) { + bool forShadowScope, + bool publicOnly) { // Check to see if the name matches a module name use'd / imported if (BlockStmt* block = toBlockStmt(scope)) { if (block->useList != NULL) { for_actuals(stmt, block->useList) { + bool isPublic = false; bool checkThisInShadowScope = false; if (UseStmt* use = toUseStmt(stmt)) { - if (use->isPrivate) { - checkThisInShadowScope = true; - } + isPublic = !use->isPrivate; + checkThisInShadowScope = use->isPrivate; + } else if (ImportStmt* imp = toImportStmt(stmt)) { + isPublic = !imp->isPrivate; } // Skip for now things that don't match the request @@ -2185,6 +2221,9 @@ static void lookupUsedImportedMod(const char* name, if (forShadowScope != checkThisInShadowScope) continue; + if (publicOnly && !isPublic) + continue; + if (UseStmt* use = toUseStmt(stmt)) { if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { if (isRepeat(modSym, symbols) == false) { diff --git a/test/visibility/except/deepUseWouldConflict.chpl b/test/visibility/except/deepUseWouldConflict.chpl index d489414c9a06..0c9d3ad330fe 100644 --- a/test/visibility/except/deepUseWouldConflict.chpl +++ b/test/visibility/except/deepUseWouldConflict.chpl @@ -1,6 +1,6 @@ module M4 { use M1 except a; - use M3; + use M3 except a; use M2; proc main() { From 4c3278eba069bfcf35e4bf323af595b7def8e56e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 11:58:21 -0500 Subject: [PATCH 24/96] Use ee instead of e to avoid Math.e --- Signed-off-by: Michael Ferguson --- test/visibility/private/uses/definesMultiUse.chpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/visibility/private/uses/definesMultiUse.chpl b/test/visibility/private/uses/definesMultiUse.chpl index c85da4b7ff22..6ce90c90c85a 100644 --- a/test/visibility/private/uses/definesMultiUse.chpl +++ b/test/visibility/private/uses/definesMultiUse.chpl @@ -16,7 +16,7 @@ module definesMultiUse { } module Inner3 { - var e: int; + var ee: int; proc f() { writeln("and this as well"); @@ -31,10 +31,10 @@ module definesMultiUse { b(); d(); f(); - if (c && e > 3) { - writeln(a - e); + if (c && ee > 3) { + writeln(a - ee); } else { - writeln(a*e); + writeln(a*ee); } } } From 4a8ddfe28b741dcca19a6810b173d395c2ad05fd Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 12:24:58 -0500 Subject: [PATCH 25/96] Adjust anotherMultipleDef and add a variant --- Signed-off-by: Michael Ferguson --- .../import/edgeCases/anotherMultipleDef.chpl | 2 +- .../import/edgeCases/anotherMultipleDef.good | 3 ++- .../import/edgeCases/anotherMultipleDef2.chpl | 21 +++++++++++++++++++ .../import/edgeCases/anotherMultipleDef2.good | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test/visibility/import/edgeCases/anotherMultipleDef2.chpl create mode 100644 test/visibility/import/edgeCases/anotherMultipleDef2.good diff --git a/test/visibility/import/edgeCases/anotherMultipleDef.chpl b/test/visibility/import/edgeCases/anotherMultipleDef.chpl index 5487aaeeae85..1af18c258c77 100644 --- a/test/visibility/import/edgeCases/anotherMultipleDef.chpl +++ b/test/visibility/import/edgeCases/anotherMultipleDef.chpl @@ -13,7 +13,7 @@ module B { module Z { import A; - use B; + public use B; proc main() { A.foo(); diff --git a/test/visibility/import/edgeCases/anotherMultipleDef.good b/test/visibility/import/edgeCases/anotherMultipleDef.good index 33fdbac80554..33e2a55ba16b 100644 --- a/test/visibility/import/edgeCases/anotherMultipleDef.good +++ b/test/visibility/import/edgeCases/anotherMultipleDef.good @@ -1 +1,2 @@ -type method A.foo() for class A +anotherMultipleDef.chpl:1: error: symbol A is multiply defined +anotherMultipleDef.chpl:7: note: also defined here diff --git a/test/visibility/import/edgeCases/anotherMultipleDef2.chpl b/test/visibility/import/edgeCases/anotherMultipleDef2.chpl new file mode 100644 index 000000000000..5487aaeeae85 --- /dev/null +++ b/test/visibility/import/edgeCases/anotherMultipleDef2.chpl @@ -0,0 +1,21 @@ +module A { + proc foo() { + writeln("Module scope A.foo()"); + } +} +module B { + class A { + proc type foo() { + writeln("type method A.foo() for class A"); + } + } +} + +module Z { + import A; + use B; + + proc main() { + A.foo(); + } +} diff --git a/test/visibility/import/edgeCases/anotherMultipleDef2.good b/test/visibility/import/edgeCases/anotherMultipleDef2.good new file mode 100644 index 000000000000..4c29c54765d3 --- /dev/null +++ b/test/visibility/import/edgeCases/anotherMultipleDef2.good @@ -0,0 +1 @@ +Module scope A.foo() From b1dbbb237f01b542d612bd8f49f92642c10e7041 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 12:26:48 -0500 Subject: [PATCH 26/96] update tests for ambiguity due to no shadow import --- Signed-off-by: Michael Ferguson --- test/visibility/import/rename/same_name_in_mod.good | 3 ++- test/visibility/import/rename/same_name_in_mod2.good | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/visibility/import/rename/same_name_in_mod.good b/test/visibility/import/rename/same_name_in_mod.good index 573541ac9702..e85218d9da7c 100644 --- a/test/visibility/import/rename/same_name_in_mod.good +++ b/test/visibility/import/rename/same_name_in_mod.good @@ -1 +1,2 @@ -0 +same_name_in_mod.chpl:7: error: symbol F is multiply defined +same_name_in_mod.chpl:1: note: also defined here diff --git a/test/visibility/import/rename/same_name_in_mod2.good b/test/visibility/import/rename/same_name_in_mod2.good index 7f305869fa7e..4d3a3b8dc1a9 100644 --- a/test/visibility/import/rename/same_name_in_mod2.good +++ b/test/visibility/import/rename/same_name_in_mod2.good @@ -1,3 +1,2 @@ -same_name_in_mod2.chpl:9: In function 'main': -same_name_in_mod2.chpl:10: error: unresolved call 'int(64).x' -same_name_in_mod2.chpl:10: note: because no functions named x found in scope +same_name_in_mod2.chpl:7: error: symbol F is multiply defined +same_name_in_mod2.chpl:1: note: symbol 'Foo', defined here, was renamed to 'F' at same_name_in_mod2.chpl:5 From 30e30d42ce75c2fb433c4bdfcebb59f8b681da05 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 12:28:51 -0500 Subject: [PATCH 27/96] Adjust for no shadow public use --- Signed-off-by: Michael Ferguson --- test/visibility/private/uses/weirdEnumHiding.chpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/visibility/private/uses/weirdEnumHiding.chpl b/test/visibility/private/uses/weirdEnumHiding.chpl index b11c7d142043..ba4d2d7275a0 100644 --- a/test/visibility/private/uses/weirdEnumHiding.chpl +++ b/test/visibility/private/uses/weirdEnumHiding.chpl @@ -21,8 +21,8 @@ module weirdEnumHiding { } module D { - public use super.C; - public use super.B; + public use super.C except checkFoo; + public use super.B except checkFoo; proc checkFoo() { writeln(foo.b); From c6287ac09d5142f380b7d2e65096f24eaf8a7fd9 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 12:50:15 -0500 Subject: [PATCH 28/96] Fix rename + recursion check For visibility/rename/backToSame*.chpl --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 57 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index b6b9ad903606..e5d2aebffc93 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -1925,6 +1925,8 @@ static bool methodMatched(BaseAST* scope, FnSymbol* method); static FnSymbol* getMethod(const char* name, Type* type); +using VisitedModulesSet = std::set>; + static void lookupUseImport(const char* name, BaseAST* context, BaseAST* scope, @@ -1932,7 +1934,7 @@ static void lookupUseImport(const char* name, std::map& renameLocs, bool storeRenames, std::map& reexportPts, - std::set& visitedModules, + VisitedModulesSet& visitedModules, bool forShadowScope, bool publicOnly); @@ -1977,7 +1979,7 @@ bool lookupThisScopeAndUses(const char* name, symbols.push_back(sym); } - std::set visitedModules; + VisitedModulesSet visitedModules; // check imports and public use // including names of modules imported or public use'd @@ -1989,6 +1991,7 @@ bool lookupThisScopeAndUses(const char* name, if (symbols.size() == 0) { // check private use only, not including names of modules // (this forms the 1st shadow scope for a private use) + visitedModules.clear(); lookupUseImport(name, context, scope, symbols, renameLocs, storeRenames, reexportPts, visitedModules, /* forShadowScope */ true, @@ -2015,12 +2018,26 @@ static void lookupUseImport(const char* name, std::map& renameLocs, bool storeRenames, std::map& reexportPts, - std::set& visitedModules, + VisitedModulesSet& visitedModules, bool forShadowScope, bool publicOnly) { // Nothing found so far, look into the uses. if (BlockStmt* block = toBlockStmt(scope)) { if (block->useList != NULL) { + + // check to see if we have already visited this scope + // if it is a module scope (to avoid infinite loop with recursive use) + if (ModuleSymbol* mod = toModuleSymbol(block->parentSymbol)) { + if (mod->block == block) { + auto pair = visitedModules.insert(std::make_pair(mod, name)); + if (pair.second == false) { + // module+name has already been visited by this function + // so don't try to visit it again + return; + } + } + } + int nUseImport = 0; for_actuals(expr, block->useList) { // Ensure we only have use or import statements in this list @@ -2100,22 +2117,16 @@ static void lookupUseImport(const char* name, } } - // For a use statement, also look into public uses + // For a use statement, also look into public uses / imports // from whatever was used. if (SymExpr* se = toSymExpr(use->src)) { if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { if (mod->block->useList != NULL) { - auto pair = visitedModules.insert(mod); - if (pair.second == false) { - // module has already been visited by this function - // so don't try to visit it again - } else { - lookupUseImport(nameToUse, context, mod->block, - symbols, renameLocs, storeRenames, - reexportPts, visitedModules, - /* forShadowScope */ false, - /* publicOnly */ true); - } + lookupUseImport(nameToUse, context, mod->block, + symbols, renameLocs, storeRenames, + reexportPts, visitedModules, + /* forShadowScope */ false, + /* publicOnly */ true); } } } @@ -2151,17 +2162,11 @@ static void lookupUseImport(const char* name, if (SymExpr* se = toSymExpr(import->src)) { if (ModuleSymbol* mod = toModuleSymbol(se->symbol())) { if (mod->block->useList != NULL) { - auto pair = visitedModules.insert(mod); - if (pair.second == false) { - // module has already been visited by this function - // so don't try to visit it again - } else { - lookupUseImport(nameToUse, context, mod->block, - symbols, renameLocs, storeRenames, - reexportPts, visitedModules, - /* forShadowScope */ false, - /* publicOnly */ true); - } + lookupUseImport(nameToUse, context, mod->block, + symbols, renameLocs, storeRenames, + reexportPts, visitedModules, + /* forShadowScope */ false, + /* publicOnly */ true); } } } From 60b2e8424d85442af770ae46fedf83cbc89b0d14 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 24 Feb 2022 16:02:08 -0500 Subject: [PATCH 29/96] Fix private module check For test/visibility/rename/renameUsedMod/renamePrivateModuleOnUse.chpl --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index e5d2aebffc93..1b7c2820286f 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -2029,6 +2029,15 @@ static void lookupUseImport(const char* name, // if it is a module scope (to avoid infinite loop with recursive use) if (ModuleSymbol* mod = toModuleSymbol(block->parentSymbol)) { if (mod->block == block) { + // if the module is private, return, + // since we can't access anything in it + // TODO: does this need to have a more involved check? + // could a private outer module use a private inner + // module and see it? + if (publicOnly && mod->hasFlag(FLAG_PRIVATE)) { + return; + } + auto pair = visitedModules.insert(std::make_pair(mod, name)); if (pair.second == false) { // module+name has already been visited by this function @@ -2231,10 +2240,12 @@ static void lookupUsedImportedMod(const char* name, if (UseStmt* use = toUseStmt(stmt)) { if (Symbol* modSym = use->checkIfModuleNameMatches(name)) { - if (isRepeat(modSym, symbols) == false) { - symbols.push_back(modSym); - if (storeRenames && use->isARename()) { - renameLocs[modSym] = &use->astloc; + if (!(publicOnly && modSym->hasFlag(FLAG_PRIVATE))) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && use->isARename()) { + renameLocs[modSym] = &use->astloc; + } } } } @@ -2242,10 +2253,12 @@ static void lookupUsedImportedMod(const char* name, // Check the name of the module if (imp->providesQualifiedAccess()) { if (Symbol* modSym = imp->checkIfModuleNameMatches(name)) { - if (isRepeat(modSym, symbols) == false) { - symbols.push_back(modSym); - if (storeRenames && imp->isARename()) { - renameLocs[modSym] = &imp->astloc; + if (!(publicOnly && modSym->hasFlag(FLAG_PRIVATE))) { + if (isRepeat(modSym, symbols) == false) { + symbols.push_back(modSym); + if (storeRenames && imp->isARename()) { + renameLocs[modSym] = &imp->astloc; + } } } } From 5ab2235e3364669b9ae91431e7dc25f5ff9369b8 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 25 Feb 2022 10:56:15 -0500 Subject: [PATCH 30/96] Fix TestSorted future --- Signed-off-by: Michael Ferguson --- test/reductions/thomasvandoren/sorted.chpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/reductions/thomasvandoren/sorted.chpl b/test/reductions/thomasvandoren/sorted.chpl index 2e5261f236c3..c37f4d8abfdf 100644 --- a/test/reductions/thomasvandoren/sorted.chpl +++ b/test/reductions/thomasvandoren/sorted.chpl @@ -3,7 +3,8 @@ * or not. */ -public use Sort; +public use Sort except isSorted; + // // BLC: For some of the reasons noted below in comments, I don't // believe this test behaves as expected (nor do I think it could, From 6e73790d06a5f1f8dc547308dd3752f2663fe386 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 25 Feb 2022 11:00:56 -0500 Subject: [PATCH 31/96] Adjust a future's .good file --- Signed-off-by: Michael Ferguson --- test/modules/vass/use-depth.good | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/modules/vass/use-depth.good b/test/modules/vass/use-depth.good index 167fe5a7ef63..8fc422a248c9 100644 --- a/test/modules/vass/use-depth.good +++ b/test/modules/vass/use-depth.good @@ -1,2 +1,6 @@ use-depth.chpl:21: error: symbol x is multiply defined use-depth.chpl:37: note: also defined here +use-depth.chpl:22: error: symbol y is multiply defined +use-depth.chpl:28: note: also defined here +use-depth.chpl:23: error: symbol z is multiply defined +use-depth.chpl:33: note: also defined here From d1b8236132b0d83e76f4d1aa0da8b39729c62968 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 25 Feb 2022 11:06:57 -0500 Subject: [PATCH 32/96] Use qualified naming to avoid std module Types --- Signed-off-by: Michael Ferguson --- .../ProtobufProtocolSupport/endToEnd/typesTest/read.chpl | 2 +- .../ProtobufProtocolSupport/endToEnd/typesTest/write.chpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/read.chpl b/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/read.chpl index 79d3ccf2ae09..abcb44130a5a 100644 --- a/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/read.chpl +++ b/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/read.chpl @@ -1,7 +1,7 @@ use typesTest; use IO; -var messageObj = new Types(); +var messageObj = new typesTest.Types(); var file = open("out", iomode.r); var readingChannel = file.reader(); diff --git a/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/write.chpl b/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/write.chpl index eb88544ad8a7..28994f0893b4 100644 --- a/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/write.chpl +++ b/test/library/packages/ProtobufProtocolSupport/endToEnd/typesTest/write.chpl @@ -4,7 +4,7 @@ use IO; var file = open("out", iomode.cw); var writingChannel = file.writer(); -var messageObj = new Types(); +var messageObj = new typesTest.Types(); messageObj.ui64 = 9223372036854; messageObj.ui32 = 429496729; From e04ae58455d75686d5c3c86ff0c02e31395418b9 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 25 Feb 2022 11:26:54 -0500 Subject: [PATCH 33/96] Adjust tests to avoid #19303 --- Signed-off-by: Michael Ferguson --- test/library/standard/GMP/ldelaney/gmp_Bigint_division.chpl | 1 + .../shootout/pidigits/thomasvandoren/pidigits-BigInt.chpl | 1 + 2 files changed, 2 insertions(+) diff --git a/test/library/standard/GMP/ldelaney/gmp_Bigint_division.chpl b/test/library/standard/GMP/ldelaney/gmp_Bigint_division.chpl index 9cc562afbb3b..b8361b141a43 100644 --- a/test/library/standard/GMP/ldelaney/gmp_Bigint_division.chpl +++ b/test/library/standard/GMP/ldelaney/gmp_Bigint_division.chpl @@ -1,4 +1,5 @@ use BigInteger; +import BigInteger.round; // avoid conflict with Math.round // Tests the division functions var a = new bigint( 8); diff --git a/test/studies/shootout/pidigits/thomasvandoren/pidigits-BigInt.chpl b/test/studies/shootout/pidigits/thomasvandoren/pidigits-BigInt.chpl index 6ddcf702eaeb..aec48dbd30fb 100644 --- a/test/studies/shootout/pidigits/thomasvandoren/pidigits-BigInt.chpl +++ b/test/studies/shootout/pidigits/thomasvandoren/pidigits-BigInt.chpl @@ -7,6 +7,7 @@ */ use BigInteger; +import BigInteger.round; // avoid conflict with Math.round // Compute n digits of Pi, 10 000 by default to match benchmark expectation. config const n = 10000; From cb1baa652a645d22c6c07ec8c8487b1b34f9476b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 1 Mar 2022 06:06:45 -0500 Subject: [PATCH 34/96] Change deepUseWouldConflict.good file instead of test --- Signed-off-by: Michael Ferguson --- test/visibility/except/deepUseWouldConflict.chpl | 4 ++-- test/visibility/except/deepUseWouldConflict.good | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/visibility/except/deepUseWouldConflict.chpl b/test/visibility/except/deepUseWouldConflict.chpl index 0c9d3ad330fe..d4d80a776209 100644 --- a/test/visibility/except/deepUseWouldConflict.chpl +++ b/test/visibility/except/deepUseWouldConflict.chpl @@ -1,12 +1,12 @@ module M4 { use M1 except a; - use M3 except a; + use M3; use M2; proc main() { writeln(b); writeln(c); writeln(a); - // a should evaluate to M2's version. + // a used to evaluate to M2's version but now conflicts } } diff --git a/test/visibility/except/deepUseWouldConflict.good b/test/visibility/except/deepUseWouldConflict.good index c4ba9bd2dd69..2fb0f6d43687 100644 --- a/test/visibility/except/deepUseWouldConflict.good +++ b/test/visibility/except/deepUseWouldConflict.good @@ -1,3 +1,2 @@ -true -14.0 -32 +deepUseSetup.chpl:4: error: symbol a is multiply defined +deepUseSetup.chpl:12: note: also defined here From 6703dbf9139e31f359a9a7fdbdd7b59db3553b62 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 1 Mar 2022 08:46:41 -0500 Subject: [PATCH 35/96] Update weirdEnumHiding to show private use --- Signed-off-by: Michael Ferguson --- test/visibility/private/uses/weirdEnumHiding.chpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/visibility/private/uses/weirdEnumHiding.chpl b/test/visibility/private/uses/weirdEnumHiding.chpl index ba4d2d7275a0..f9580c753153 100644 --- a/test/visibility/private/uses/weirdEnumHiding.chpl +++ b/test/visibility/private/uses/weirdEnumHiding.chpl @@ -21,8 +21,8 @@ module weirdEnumHiding { } module D { - public use super.C except checkFoo; - public use super.B except checkFoo; + private use super.C; // or public use super.C except checkFoo; + private use super.B; // or public use super.B except checkFoo; proc checkFoo() { writeln(foo.b); From 5f473116d9cb03a35d5254886316e605494448fa Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 1 Mar 2022 11:49:54 -0500 Subject: [PATCH 36/96] Keep public use but rename checkFoo functions To better match the original intent of this test --- Signed-off-by: Michael Ferguson --- .../visibility/private/uses/weirdEnumHiding.chpl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/visibility/private/uses/weirdEnumHiding.chpl b/test/visibility/private/uses/weirdEnumHiding.chpl index f9580c753153..db42e3e66d2f 100644 --- a/test/visibility/private/uses/weirdEnumHiding.chpl +++ b/test/visibility/private/uses/weirdEnumHiding.chpl @@ -7,7 +7,7 @@ module weirdEnumHiding { module B { public use super.A; - proc checkFoo() { + proc checkFooB() { writeln(foo.b); } } @@ -15,23 +15,23 @@ module weirdEnumHiding { module C { private use super.A; - proc checkFoo() { + proc checkFooC() { writeln(foo.b); } } module D { - private use super.C; // or public use super.C except checkFoo; - private use super.B; // or public use super.B except checkFoo; + public use super.C; + public use super.B; - proc checkFoo() { + proc checkFooD() { writeln(foo.b); } } proc main() { - B.checkFoo(); - C.checkFoo(); - D.checkFoo(); + B.checkFooB(); + C.checkFooC(); + D.checkFooD(); } } From 8ea910e2b9c8e3c567684e37946c057cf6cb2238 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 4 Mar 2022 18:14:59 -0500 Subject: [PATCH 37/96] Add variant that calls mCallFunc --- Signed-off-by: Michael Ferguson --- test/functions/generic/poi/issue-19198m.chpl | 28 ++++++++++++++++++++ test/functions/generic/poi/issue-19198m.good | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 test/functions/generic/poi/issue-19198m.chpl create mode 100644 test/functions/generic/poi/issue-19198m.good diff --git a/test/functions/generic/poi/issue-19198m.chpl b/test/functions/generic/poi/issue-19198m.chpl new file mode 100644 index 000000000000..be95f510aeb8 --- /dev/null +++ b/test/functions/generic/poi/issue-19198m.chpl @@ -0,0 +1,28 @@ +module G { + proc genericfunc(param p) { + helper1(); + } +} + +module M { + use G; + proc mCallFunc() { + writeln("mCallFunc"); + genericfunc(1); + } + proc helper1() { writeln("M.helper1"); } +} + +module N { + use G,M; + proc helper1() { writeln("N.helper1"); } + proc helper1() { writeln("N.helper1 mark two"); } + proc nCallFunc() { + writeln("nCallFunc"); + genericfunc(1); + } + + proc main() { + mCallFunc(); + } +} diff --git a/test/functions/generic/poi/issue-19198m.good b/test/functions/generic/poi/issue-19198m.good new file mode 100644 index 000000000000..152652608859 --- /dev/null +++ b/test/functions/generic/poi/issue-19198m.good @@ -0,0 +1,2 @@ +mCallFunc +M.helper1 From 495dec31b06d4c05caecdfa8245c6262310def33 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 4 Mar 2022 18:42:25 -0500 Subject: [PATCH 38/96] Give the two x variables different values --- Signed-off-by: Michael Ferguson --- test/modules/shadowing/var-shadows-private-use.chpl | 4 ++-- test/modules/shadowing/var-shadows-private-use.good | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/modules/shadowing/var-shadows-private-use.chpl b/test/modules/shadowing/var-shadows-private-use.chpl index 851885517077..32eb7b8e3f08 100644 --- a/test/modules/shadowing/var-shadows-private-use.chpl +++ b/test/modules/shadowing/var-shadows-private-use.chpl @@ -1,10 +1,10 @@ module M { - var x: int; + var x: int = 1; } module N { private use M; - var x: int; + var x: int = 2; proc main() { writeln(x); diff --git a/test/modules/shadowing/var-shadows-private-use.good b/test/modules/shadowing/var-shadows-private-use.good index 573541ac9702..0cfbf08886fc 100644 --- a/test/modules/shadowing/var-shadows-private-use.good +++ b/test/modules/shadowing/var-shadows-private-use.good @@ -1 +1 @@ -0 +2 From bb87175be81327da53d15170e4c62ff1d1a2d36f Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 7 Mar 2022 10:33:05 -0500 Subject: [PATCH 39/96] Continue with module counts / class count but don't public use --- Signed-off-by: Michael Ferguson --- test/reductions/thomasvandoren/{CountsMod.chpl => counts.chpl} | 0 .../thomasvandoren/{CountsMod.notest => counts.notest} | 0 test/reductions/thomasvandoren/scanCountsInherit.chpl | 2 +- test/reductions/thomasvandoren/test/TestCounts.chpl | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename test/reductions/thomasvandoren/{CountsMod.chpl => counts.chpl} (100%) rename test/reductions/thomasvandoren/{CountsMod.notest => counts.notest} (100%) diff --git a/test/reductions/thomasvandoren/CountsMod.chpl b/test/reductions/thomasvandoren/counts.chpl similarity index 100% rename from test/reductions/thomasvandoren/CountsMod.chpl rename to test/reductions/thomasvandoren/counts.chpl diff --git a/test/reductions/thomasvandoren/CountsMod.notest b/test/reductions/thomasvandoren/counts.notest similarity index 100% rename from test/reductions/thomasvandoren/CountsMod.notest rename to test/reductions/thomasvandoren/counts.notest diff --git a/test/reductions/thomasvandoren/scanCountsInherit.chpl b/test/reductions/thomasvandoren/scanCountsInherit.chpl index 0b3a287d09a6..6ef8ab266896 100644 --- a/test/reductions/thomasvandoren/scanCountsInherit.chpl +++ b/test/reductions/thomasvandoren/scanCountsInherit.chpl @@ -8,7 +8,7 @@ * could determine a ranking of the particles within each octant. */ -public use CountsMod; +use counts; class scanCountsInherit : counts { // Track the current value, so it can be used in generate() method. Use min() diff --git a/test/reductions/thomasvandoren/test/TestCounts.chpl b/test/reductions/thomasvandoren/test/TestCounts.chpl index 034bfa5afc39..caf90f2de2e5 100644 --- a/test/reductions/thomasvandoren/test/TestCounts.chpl +++ b/test/reductions/thomasvandoren/test/TestCounts.chpl @@ -2,7 +2,7 @@ * Verify user defined counts reduction works with defaults. */ -use CountsMod; +use counts; var particles = [6, 7, 6, 3, 8, 2, 8, 4, 8, 3], octantCounts = counts reduce particles; From 327b59f2a0654c73468235d3ec8df506e5604cb1 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 7 Mar 2022 10:39:24 -0500 Subject: [PATCH 40/96] Adjust which is code clone to preserve history --- Signed-off-by: Michael Ferguson --- test/visibility/import/edgeCases/anotherMultipleDef.chpl | 2 +- test/visibility/import/edgeCases/anotherMultipleDef.good | 3 +-- test/visibility/import/edgeCases/anotherMultipleDef2.chpl | 2 +- test/visibility/import/edgeCases/anotherMultipleDef2.good | 3 ++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/visibility/import/edgeCases/anotherMultipleDef.chpl b/test/visibility/import/edgeCases/anotherMultipleDef.chpl index 1af18c258c77..5487aaeeae85 100644 --- a/test/visibility/import/edgeCases/anotherMultipleDef.chpl +++ b/test/visibility/import/edgeCases/anotherMultipleDef.chpl @@ -13,7 +13,7 @@ module B { module Z { import A; - public use B; + use B; proc main() { A.foo(); diff --git a/test/visibility/import/edgeCases/anotherMultipleDef.good b/test/visibility/import/edgeCases/anotherMultipleDef.good index 33e2a55ba16b..4c29c54765d3 100644 --- a/test/visibility/import/edgeCases/anotherMultipleDef.good +++ b/test/visibility/import/edgeCases/anotherMultipleDef.good @@ -1,2 +1 @@ -anotherMultipleDef.chpl:1: error: symbol A is multiply defined -anotherMultipleDef.chpl:7: note: also defined here +Module scope A.foo() diff --git a/test/visibility/import/edgeCases/anotherMultipleDef2.chpl b/test/visibility/import/edgeCases/anotherMultipleDef2.chpl index 5487aaeeae85..1af18c258c77 100644 --- a/test/visibility/import/edgeCases/anotherMultipleDef2.chpl +++ b/test/visibility/import/edgeCases/anotherMultipleDef2.chpl @@ -13,7 +13,7 @@ module B { module Z { import A; - use B; + public use B; proc main() { A.foo(); diff --git a/test/visibility/import/edgeCases/anotherMultipleDef2.good b/test/visibility/import/edgeCases/anotherMultipleDef2.good index 4c29c54765d3..49d55a67eb23 100644 --- a/test/visibility/import/edgeCases/anotherMultipleDef2.good +++ b/test/visibility/import/edgeCases/anotherMultipleDef2.good @@ -1 +1,2 @@ -Module scope A.foo() +anotherMultipleDef2.chpl:1: error: symbol A is multiply defined +anotherMultipleDef2.chpl:7: note: also defined here From 9023947b33238a70e4410fcfab1468765793ac3e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 7 Mar 2022 16:19:02 -0500 Subject: [PATCH 41/96] Public use doesn't bring in module name --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 3 ++ modules/internal/ChapelStandard.chpl | 42 +++++++++++++++++++ .../use-no-qualified/public-use-no-mod1.chpl | 11 +++++ .../use-no-qualified/public-use-no-mod1.good | 2 + .../use-no-qualified/public-use-no-mod2.chpl | 11 +++++ .../use-no-qualified/public-use-no-mod2.good | 2 + 6 files changed, 71 insertions(+) create mode 100644 test/visibility/use-no-qualified/public-use-no-mod1.chpl create mode 100644 test/visibility/use-no-qualified/public-use-no-mod1.good create mode 100644 test/visibility/use-no-qualified/public-use-no-mod2.chpl create mode 100644 test/visibility/use-no-qualified/public-use-no-mod2.good diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 1b7c2820286f..4430926854a3 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -2225,6 +2225,9 @@ static void lookupUsedImportedMod(const char* name, if (UseStmt* use = toUseStmt(stmt)) { isPublic = !use->isPrivate; checkThisInShadowScope = use->isPrivate; + // don't bring in the module name for 'public use' at all + if (isPublic) + continue; } else if (ImportStmt* imp = toImportStmt(stmt)) { isPublic = !imp->isPrivate; } diff --git a/modules/internal/ChapelStandard.chpl b/modules/internal/ChapelStandard.chpl index 09b30bd159d9..820d4a06cdd4 100644 --- a/modules/internal/ChapelStandard.chpl +++ b/modules/internal/ChapelStandard.chpl @@ -26,50 +26,92 @@ module ChapelStandard { // Internal, but uses standard/CommDiagnostics // Internal modules. + public import CString; public use CString; + public import Bytes; public use Bytes; + public import String; public use String; + public import OwnedObject; public use OwnedObject; + public import SharedObject; public use SharedObject; + public import ChapelEnv; public use ChapelEnv; + public import ChapelBase; public use ChapelBase; + public import Atomics; public use Atomics; + public import NetworkAtomics; public use NetworkAtomics; + public import NetworkAtomicTypes; public use NetworkAtomicTypes; + public import AtomicsCommon; public use AtomicsCommon; + public import ChapelIteratorSupport; public use ChapelIteratorSupport; + public import ChapelThreads; public use ChapelThreads; + public import ChapelTuple; public use ChapelTuple; + public import ChapelRange; public use ChapelRange; + public import ChapelReduce; public use ChapelReduce; + public import ChapelSyncvar; public use ChapelSyncvar; + public import ChapelTaskDataHelp; public use ChapelTaskDataHelp; public use LocaleModel as _; // let LocaleModel refer to the class + public import ChapelLocale; public use ChapelLocale; + public import ChapelPrivatization; public use ChapelPrivatization; + public import DefaultRectangular; // This might be able to go just after Atomics public use DefaultRectangular; // This might be able to go just after Atomics + public import LocalesArray; public use LocalesArray; + public import ChapelArray; public use ChapelArray; + public import ChapelDistribution; public use ChapelDistribution; + public import ChapelAutoLocalAccess; public use ChapelAutoLocalAccess; + public import ChapelIO; public use ChapelIO; + public import LocaleTree; public use LocaleTree; + public import ChapelHashing; public use ChapelHashing; + public import DefaultAssociative; public use DefaultAssociative; + public import DefaultSparse; public use DefaultSparse; + public import ChapelTaskID; public use ChapelTaskID; + public import ChapelTaskTable; public use ChapelTaskTable; + public import MemTracking; public use MemTracking; + public import ChapelUtil; public use ChapelUtil; + public import Errors; public use Errors; + public import ChapelTaskData; public use ChapelTaskData; + public import ChapelSerializedBroadcast; public use ChapelSerializedBroadcast; + public import ExportWrappers; public use ExportWrappers; + public import ChapelAutoAggregation; public use ChapelAutoAggregation; // Standard modules. + public import Types; public use Types; + public import Math; public use Math; + public import VectorizingIterator; public use VectorizingIterator; use stopInitCommDiags; // Internal, but uses standard/CommDiagnostics diff --git a/test/visibility/use-no-qualified/public-use-no-mod1.chpl b/test/visibility/use-no-qualified/public-use-no-mod1.chpl new file mode 100644 index 000000000000..483b593c1b2c --- /dev/null +++ b/test/visibility/use-no-qualified/public-use-no-mod1.chpl @@ -0,0 +1,11 @@ +module M { + var X: int; +} + +module N { + public use M; + + proc main() { + writeln(M.X); // nope, M was not brought in + } +} diff --git a/test/visibility/use-no-qualified/public-use-no-mod1.good b/test/visibility/use-no-qualified/public-use-no-mod1.good new file mode 100644 index 000000000000..76080607246e --- /dev/null +++ b/test/visibility/use-no-qualified/public-use-no-mod1.good @@ -0,0 +1,2 @@ +public-use-no-mod1.chpl:8: In function 'main': +public-use-no-mod1.chpl:9: error: 'M' undeclared (first use this function) diff --git a/test/visibility/use-no-qualified/public-use-no-mod2.chpl b/test/visibility/use-no-qualified/public-use-no-mod2.chpl new file mode 100644 index 000000000000..da4d47591ab9 --- /dev/null +++ b/test/visibility/use-no-qualified/public-use-no-mod2.chpl @@ -0,0 +1,11 @@ +module M { + proc f() { writeln("M.f"); } +} + +module N { + public use M; + + proc main() { + M.f(); // nope, M was not brought in + } +} diff --git a/test/visibility/use-no-qualified/public-use-no-mod2.good b/test/visibility/use-no-qualified/public-use-no-mod2.good new file mode 100644 index 000000000000..58e211f0b28b --- /dev/null +++ b/test/visibility/use-no-qualified/public-use-no-mod2.good @@ -0,0 +1,2 @@ +public-use-no-mod2.chpl:8: In function 'main': +public-use-no-mod2.chpl:9: error: 'M' undeclared (first use this function) From 7c6098599ae39f56a34cf03b802ee77bb0f8420a Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 7 Mar 2022 17:52:36 -0500 Subject: [PATCH 42/96] Add import Path to MasonPublish. --- Signed-off-by: Michael Ferguson --- tools/mason/MasonPublish.chpl | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index 825772bdac80..8496e3b9ee3e 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -31,6 +31,7 @@ use MasonUtils; use Random; use Subprocess; use TOML; +import Path; /* Top Level procedure that gets called from mason.chpl that takes in arguments from command line. If --dry-run is passed then it checks to see if the package is able to be published. From 5f71c59b74f1958f5afd6ce6ae00978a044a488e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 10:19:42 -0500 Subject: [PATCH 43/96] Un-future now passing future (Passes due to 'public use not having shadow scope' and the previous commit adjusting the .good file) --- Signed-off-by: Michael Ferguson --- test/modules/vass/use-depth.bad | 2 -- test/modules/vass/use-depth.future | 38 ------------------------------ 2 files changed, 40 deletions(-) delete mode 100644 test/modules/vass/use-depth.bad delete mode 100644 test/modules/vass/use-depth.future diff --git a/test/modules/vass/use-depth.bad b/test/modules/vass/use-depth.bad deleted file mode 100644 index a9ec55b67d95..000000000000 --- a/test/modules/vass/use-depth.bad +++ /dev/null @@ -1,2 +0,0 @@ -use-depth.chpl:23: error: symbol z is multiply defined -use-depth.chpl:33: note: also defined here diff --git a/test/modules/vass/use-depth.future b/test/modules/vass/use-depth.future deleted file mode 100644 index 211d36773b69..000000000000 --- a/test/modules/vass/use-depth.future +++ /dev/null @@ -1,38 +0,0 @@ -semantic: should the depth of the 'use' chain matter? - -Context: symbols 'x' are defined in two different modules M11 and M222. -Those modules are 'use'ed through different-depth use chains -e.g. by the main module. - -Should a reference to 'x' in the main module be an "it is ambiguous" error? -Or should M11's 'x' shadow M222's 'x' because the depth of the use chain -of M222 is longer? - -Currently Chapel prefers symbols from the shorter-depth-use-chain module. -In a discussion July 2015, Brad suggested that the depth should be used -to shadow symbols in deeper modules along the same use chain, e.g.: - - use M1; - writeln(x); // OK - use M1's x - module M1 { var x: int; use M11; } - module M11 { var x: real; } // shadowed by M1's x - -and that the depth should not be used to prioritize among independent -use chains. - -Related: when the use chains have a diamond shape and 'x' is defined -only at the bottom of the diamond, references to 'x' should not be -considered conflicting under either choice above: - - use M1; - use M2; - writeln(x); // OK - use M3's x - module M1 { use M3; } - module M2 { use M3; } - module M3 { var x: real; } - -Related, not covered in this future: should the depth of 'use' -affect determination of the more specific function during resolution? - -Note that this discussion applies to using modules via 'use' statements. -It does not apply to explicit naming. From ed891987e865d6d81647e66786c3d085f3516396 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 10:34:26 -0500 Subject: [PATCH 44/96] Allow 'public use Foo as F' to bring in F The alternative is making this case an error. Here I think it is OK because the user has opted in to the name. --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 4430926854a3..6c5af60b3f98 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -2226,7 +2226,9 @@ static void lookupUsedImportedMod(const char* name, isPublic = !use->isPrivate; checkThisInShadowScope = use->isPrivate; // don't bring in the module name for 'public use' at all - if (isPublic) + // unless it is renamed as in 'use Foo as F' + // and then it is OK because the user has opted in to it. + if (isPublic && !use->isARename()) continue; } else if (ImportStmt* imp = toImportStmt(stmt)) { isPublic = !imp->isPrivate; From 498c460eb0cc767b5612e7ad49b6ec5fdf8a1442 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 10:37:20 -0500 Subject: [PATCH 45/96] Add variant of test to do 'public use Foo as Foo' --- Signed-off-by: Michael Ferguson --- .../rename/renameUsedMod/renamePublicUse4.chpl | 17 +++++++++++++++++ .../rename/renameUsedMod/renamePublicUse4.good | 1 + 2 files changed, 18 insertions(+) create mode 100644 test/visibility/rename/renameUsedMod/renamePublicUse4.chpl create mode 100644 test/visibility/rename/renameUsedMod/renamePublicUse4.good diff --git a/test/visibility/rename/renameUsedMod/renamePublicUse4.chpl b/test/visibility/rename/renameUsedMod/renamePublicUse4.chpl new file mode 100644 index 000000000000..1f427d02abc0 --- /dev/null +++ b/test/visibility/rename/renameUsedMod/renamePublicUse4.chpl @@ -0,0 +1,17 @@ +module Foo { + var x: int; +} +module Bar { + public use Foo as Foo; + + var y: bool; +} +module User { + use Bar; + + proc main() { + // Should work, because the user has opted in to having Bar + // bring in the name Foo. + writeln(Foo.x); + } +} diff --git a/test/visibility/rename/renameUsedMod/renamePublicUse4.good b/test/visibility/rename/renameUsedMod/renamePublicUse4.good new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/test/visibility/rename/renameUsedMod/renamePublicUse4.good @@ -0,0 +1 @@ +0 From a237c58d5e1d6e78925059e4c3d89411172fcbfd Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 10:54:23 -0500 Subject: [PATCH 46/96] Update importAndImportFromUse.good and add clone Qualified access no longer available from public use --- Signed-off-by: Michael Ferguson --- .../importAndImportFromUse.good | 5 ++-- .../importAndImportFromUse2.chpl | 27 +++++++++++++++++++ .../importAndImportFromUse2.good | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.chpl create mode 100644 test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.good diff --git a/test/visibility/import/public/qualifiedReexport/importAndImportFromUse.good b/test/visibility/import/public/qualifiedReexport/importAndImportFromUse.good index ec220522d392..4015ab90daed 100644 --- a/test/visibility/import/public/qualifiedReexport/importAndImportFromUse.good +++ b/test/visibility/import/public/qualifiedReexport/importAndImportFromUse.good @@ -1,2 +1,3 @@ -4 -In A.foo() +importAndImportFromUse.chpl:23: In function 'main': +importAndImportFromUse.chpl:24: error: 'B' undeclared (first use this function) +importAndImportFromUse.chpl:25: error: 'C' undeclared (first use this function) diff --git a/test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.chpl b/test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.chpl new file mode 100644 index 000000000000..f265220e036c --- /dev/null +++ b/test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.chpl @@ -0,0 +1,27 @@ +// Tests behavior when a module is imported from two different paths +module A { + var x: int = 4; + proc foo() { + writeln("In A.foo()"); + } +} +module B { + public import A.x; +} + +module C { + public import A.foo; +} + +module D { + public use B as B, C as C; +} + +module E { + use D; + + proc main() { + writeln(B.x); + C.foo(); + } +} diff --git a/test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.good b/test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.good new file mode 100644 index 000000000000..ec220522d392 --- /dev/null +++ b/test/visibility/import/public/qualifiedReexport/importAndImportFromUse2.good @@ -0,0 +1,2 @@ +4 +In A.foo() From bdd52876fd3a4f2cd1f8e4d4475e030a45662b9e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 11:20:04 -0500 Subject: [PATCH 47/96] Adjust multipleUnqualified Approach taken here was to allow the tests to show an error if it would occur after the variable is resolved in scope resolve, but to remove the new error for those calling a function (since otherwise we won't be testing the behavior of the function call). --- Signed-off-by: Michael Ferguson --- .../multipleUnqualified/useAndImport-useExcept1a.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useExcept1a.good | 5 ++--- .../multipleUnqualified/useAndImport-useExcept1b.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useExcept1b.good | 2 -- .../multipleUnqualified/useAndImport-useExcept1c.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useExcept1c.good | 5 ++--- .../multipleUnqualified/useAndImport-useExcept1d.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useExcept1d.good | 5 ++--- .../multipleUnqualified/useAndImport-useOnly1a.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useOnly1a.good | 2 -- .../multipleUnqualified/useAndImport-useOnly1b.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useOnly1b.good | 2 -- .../multipleUnqualified/useAndImport-useOnly1c.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useOnly1c.good | 5 ++--- .../multipleUnqualified/useAndImport-useOnly1d.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useOnly1d.good | 5 ++--- .../multipleUnqualified/useAndImport-useOnlyNothing1a.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useOnlyNothing1a.good | 5 ++--- .../multipleUnqualified/useAndImport-useOnlyNothing1b.chpl | 6 +++--- .../multipleUnqualified/useAndImport-useOnlyNothing1b.good | 5 ++--- 20 files changed, 44 insertions(+), 57 deletions(-) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.chpl index 1a289a898b4d..ab28249070f4 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.chpl @@ -20,8 +20,8 @@ module D { proc main() { // writeln(x); // Won't work - writeln(A.x); - foo(); - A.foo(); + foo(); // OK: comes from both use and import + writeln(A.x); // error: A not brought in here + A.foo(); // error: A not brought in here } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.good index fe87583de0ba..4b4eb60ad299 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1a.good @@ -1,3 +1,2 @@ -4 -In A.foo() -In A.foo() +useAndImport-useExcept1a.chpl:21: In function 'main': +useAndImport-useExcept1a.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.chpl index 96752b972df0..2ff52d8b4aa2 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.chpl @@ -20,8 +20,8 @@ module D { proc main() { // writeln(x); // Won't work - writeln(A.x); - foo(); - A.foo(); + foo(); // OK: brought in by import + //writeln(A.x); // error: A not brought in + //A.foo(); // error: A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.good index fe87583de0ba..66a0571258db 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1b.good @@ -1,3 +1 @@ -4 -In A.foo() In A.foo() diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.chpl index 142514593cdd..3518e6a6028f 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.chpl @@ -19,9 +19,9 @@ module D { use B, C; proc main() { - writeln(x); - writeln(A.x); + writeln(x); // OK, brought in by import // foo(); // Won't work - A.foo(); + writeln(A.x); // error: A not brought in + A.foo(); // error: A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.good index 986d83f3aea0..c1365f40a32f 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1c.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useExcept1c.chpl:21: In function 'main': +useAndImport-useExcept1c.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.chpl index 8fe6b1cfce4b..f15c5f83251e 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.chpl @@ -19,9 +19,9 @@ module D { use B, C; proc main() { - writeln(x); - writeln(A.x); + writeln(x); // OK, brought in by import // foo(); // Won't work - A.foo(); + writeln(A.x); // error: A not brought in + A.foo(); // error: A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.good index 986d83f3aea0..5942ac9db8a2 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useExcept1d.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useExcept1d.chpl:21: In function 'main': +useAndImport-useExcept1d.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.chpl index 23e5d9771184..40c53e653d43 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.chpl @@ -20,8 +20,8 @@ module D { proc main() { // writeln(x); // Won't work - writeln(A.x); - foo(); - A.foo(); + foo(); // OK - brought in by import + //writeln(A.x); // error: A not brought in + //A.foo(); // error: A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.good index fe87583de0ba..66a0571258db 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1a.good @@ -1,3 +1 @@ -4 -In A.foo() In A.foo() diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.chpl index e8623ae1c703..62974bc5fc25 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.chpl @@ -20,8 +20,8 @@ module D { proc main() { // writeln(x); // Won't work - writeln(A.x); - foo(); - A.foo(); + foo(); // OK: brought in by import + //writeln(A.x); // error: A not brought in + //A.foo(); // error: A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.good index fe87583de0ba..66a0571258db 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1b.good @@ -1,3 +1 @@ -4 -In A.foo() In A.foo() diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.chpl index d20298cf3e6f..e858d75ec7c1 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.chpl @@ -19,9 +19,9 @@ module D { use B, C; proc main() { - writeln(x); - writeln(A.x); + writeln(x); // OK: brought in by import and use // foo(); // Won't work - A.foo(); + writeln(A.x); // error: A not brought in + A.foo(); // error: A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.good index 986d83f3aea0..c9588f495d17 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1c.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useOnly1c.chpl:21: In function 'main': +useAndImport-useOnly1c.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.chpl index 6703b207cb1a..92f2cdf0685f 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.chpl @@ -19,9 +19,9 @@ module D { use B, C; proc main() { - writeln(x); - writeln(A.x); + writeln(x); // OK - x brought in by import and use // foo(); // Won't work - A.foo(); + writeln(A.x); // error - A not brought in + A.foo(); // error - A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.good index 986d83f3aea0..4765ac1c0eff 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnly1d.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useOnly1d.chpl:21: In function 'main': +useAndImport-useOnly1d.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl index 5ddd643873f6..e8d85b97d8f0 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl @@ -19,9 +19,9 @@ module D { use B, C; proc main() { - writeln(x); - writeln(A.x); + writeln(x); // OK - brought in by import // foo(); // Also won't work - A.foo(); + writeln(A.x); // error - A not brought in + A.foo(); // error - A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good index 986d83f3aea0..3377877a4d18 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useOnlyNothing1a.chpl:21: In function 'main': +useAndImport-useOnlyNothing1a.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl index ca2536f9d4fb..f8b02f576b4d 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl @@ -19,9 +19,9 @@ module D { use B, C; proc main() { - writeln(x); - writeln(A.x); + writeln(x); // OK - brought in by import // foo(); // Also won't work - A.foo(); + writeln(A.x); // error - A not brought in + A.foo(); // error - A not brought in } } diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good index 986d83f3aea0..e2fb2fd62ad6 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useOnlyNothing1b.chpl:21: In function 'main': +useAndImport-useOnlyNothing1b.chpl:24: error: 'A' undeclared (first use this function) From fdff165f04eedb0dfa0cd1117c621d8bba9e83ac Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 11:24:36 -0500 Subject: [PATCH 48/96] Adjust tests in visibility/import to have public use --- Signed-off-by: Michael Ferguson --- test/visibility/import/useAndImport-useExcept1a.chpl | 2 +- test/visibility/import/useAndImport-useExcept1b.chpl | 2 +- test/visibility/import/useAndImport-useExcept1c.chpl | 2 +- test/visibility/import/useAndImport-useExcept1d.chpl | 2 +- test/visibility/import/useAndImport-useOnly1a.chpl | 2 +- test/visibility/import/useAndImport-useOnly1b.chpl | 2 +- test/visibility/import/useAndImport-useOnly1c.chpl | 2 +- test/visibility/import/useAndImport-useOnly1d.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing1a.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing1b.chpl | 2 +- test/visibility/import/useAndImport.chpl | 2 +- test/visibility/import/useAndImport2.chpl | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/visibility/import/useAndImport-useExcept1a.chpl b/test/visibility/import/useAndImport-useExcept1a.chpl index 17d87576d695..4da639102fac 100644 --- a/test/visibility/import/useAndImport-useExcept1a.chpl +++ b/test/visibility/import/useAndImport-useExcept1a.chpl @@ -12,7 +12,7 @@ module B { } module C { - import A; + public import A; } module D { diff --git a/test/visibility/import/useAndImport-useExcept1b.chpl b/test/visibility/import/useAndImport-useExcept1b.chpl index c8214da9aa56..24d269e53828 100644 --- a/test/visibility/import/useAndImport-useExcept1b.chpl +++ b/test/visibility/import/useAndImport-useExcept1b.chpl @@ -8,7 +8,7 @@ module A { } } module B { - import A; + public import A; } module C { diff --git a/test/visibility/import/useAndImport-useExcept1c.chpl b/test/visibility/import/useAndImport-useExcept1c.chpl index 4276742c02c8..e8b6f6e0debd 100644 --- a/test/visibility/import/useAndImport-useExcept1c.chpl +++ b/test/visibility/import/useAndImport-useExcept1c.chpl @@ -12,7 +12,7 @@ module B { } module C { - import A; + public import A; } module D { diff --git a/test/visibility/import/useAndImport-useExcept1d.chpl b/test/visibility/import/useAndImport-useExcept1d.chpl index 570cbe9bb2b2..d7bb71c99fcf 100644 --- a/test/visibility/import/useAndImport-useExcept1d.chpl +++ b/test/visibility/import/useAndImport-useExcept1d.chpl @@ -8,7 +8,7 @@ module A { } } module B { - import A; + public import A; } module C { diff --git a/test/visibility/import/useAndImport-useOnly1a.chpl b/test/visibility/import/useAndImport-useOnly1a.chpl index d13d045b1cff..9ec7c73a7cdc 100644 --- a/test/visibility/import/useAndImport-useOnly1a.chpl +++ b/test/visibility/import/useAndImport-useOnly1a.chpl @@ -12,7 +12,7 @@ module B { } module C { - import A; + public import A; } module D { diff --git a/test/visibility/import/useAndImport-useOnly1b.chpl b/test/visibility/import/useAndImport-useOnly1b.chpl index 7b72fc9ca28d..b4a27693bbcc 100644 --- a/test/visibility/import/useAndImport-useOnly1b.chpl +++ b/test/visibility/import/useAndImport-useOnly1b.chpl @@ -8,7 +8,7 @@ module A { } } module B { - import A; + public import A; } module C { diff --git a/test/visibility/import/useAndImport-useOnly1c.chpl b/test/visibility/import/useAndImport-useOnly1c.chpl index 0a41a6c3ac4f..669caa3cc296 100644 --- a/test/visibility/import/useAndImport-useOnly1c.chpl +++ b/test/visibility/import/useAndImport-useOnly1c.chpl @@ -12,7 +12,7 @@ module B { } module C { - import A; + public import A; } module D { diff --git a/test/visibility/import/useAndImport-useOnly1d.chpl b/test/visibility/import/useAndImport-useOnly1d.chpl index 1b93876d7ddd..f84336cc4aa4 100644 --- a/test/visibility/import/useAndImport-useOnly1d.chpl +++ b/test/visibility/import/useAndImport-useOnly1d.chpl @@ -8,7 +8,7 @@ module A { } } module B { - import A; + public import A; } module C { diff --git a/test/visibility/import/useAndImport-useOnlyNothing1a.chpl b/test/visibility/import/useAndImport-useOnlyNothing1a.chpl index ada97107c983..465c5c4ee21c 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1a.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing1a.chpl @@ -12,7 +12,7 @@ module B { } module C { - import A; + public import A; } module D { diff --git a/test/visibility/import/useAndImport-useOnlyNothing1b.chpl b/test/visibility/import/useAndImport-useOnlyNothing1b.chpl index 5ed5dc0c4a5c..60c9da23b887 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1b.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing1b.chpl @@ -8,7 +8,7 @@ module A { } } module B { - import A; + public import A; } module C { diff --git a/test/visibility/import/useAndImport.chpl b/test/visibility/import/useAndImport.chpl index 22a2618c6ef9..72dbb48013ad 100644 --- a/test/visibility/import/useAndImport.chpl +++ b/test/visibility/import/useAndImport.chpl @@ -10,7 +10,7 @@ module B { } module C { - import A; + public import A; } module D { diff --git a/test/visibility/import/useAndImport2.chpl b/test/visibility/import/useAndImport2.chpl index 73dc67a87979..4b5e8d9fea8c 100644 --- a/test/visibility/import/useAndImport2.chpl +++ b/test/visibility/import/useAndImport2.chpl @@ -6,7 +6,7 @@ module A { } } module B { - import A; + public import A; } module C { From 5915abaabc66504ba7f8d62cd242abd09de2c472 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 11:54:32 -0500 Subject: [PATCH 49/96] Use 'use A as A' in this directory to keep tests as they were --- Signed-off-by: Michael Ferguson --- .../import/enablesUnqualified/useAndImport-useExcept1a.chpl | 2 +- .../import/enablesUnqualified/useAndImport-useExcept1b.chpl | 2 +- .../import/enablesUnqualified/useAndImport-useExcept1c.chpl | 2 +- .../import/enablesUnqualified/useAndImport-useExcept1d.chpl | 2 +- .../import/enablesUnqualified/useAndImport-useOnly1a.chpl | 2 +- .../import/enablesUnqualified/useAndImport-useOnly1b.chpl | 2 +- .../import/enablesUnqualified/useAndImport-useOnly1c.chpl | 2 +- .../import/enablesUnqualified/useAndImport-useOnly1d.chpl | 2 +- .../enablesUnqualified/useAndImport-useOnlyNothing1a.chpl | 2 +- .../enablesUnqualified/useAndImport-useOnlyNothing1b.chpl | 2 +- test/visibility/import/enablesUnqualified/useAndImport.chpl | 2 +- test/visibility/import/enablesUnqualified/useAndImport2.chpl | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1a.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1a.chpl index d8141584719e..736fbcdce3f9 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1a.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A except x; + public use A as A except x; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1b.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1b.chpl index 7ffb368ed942..3956c8dcf2ca 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1b.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1b.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A except x; + public use A as A except x; } module D { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1c.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1c.chpl index 39204051d1d4..a55ca3c79aea 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1c.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1c.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A except foo; + public use A as A except foo; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1d.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1d.chpl index d82d7de271ce..b13cc5d9e616 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useExcept1d.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useExcept1d.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A except foo; + public use A as A except foo; } module D { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1a.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1a.chpl index ee1952fa7199..4718daa92bc5 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1a.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only foo; + public use A as A only foo; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1b.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1b.chpl index afbb2bc53679..1dd4b5207e30 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1b.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1b.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A only foo; + public use A as A only foo; } module D { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1c.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1c.chpl index e77bee2e8c0a..1176508cd50f 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1c.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1c.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only x; + public use A as A only x; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1d.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1d.chpl index 820ed28ca5f7..56b112b004cc 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnly1d.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnly1d.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A only x; + public use A as A only x; } module D { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1a.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1a.chpl index 6ed16778d20b..95b0ea075946 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1a.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1b.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1b.chpl index 7227ed4c5abe..f4762357c1bf 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1b.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing1b.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/enablesUnqualified/useAndImport.chpl b/test/visibility/import/enablesUnqualified/useAndImport.chpl index 9131a3dd910b..88d2aafa0fb8 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport.chpl @@ -6,7 +6,7 @@ module A { } } module B { - public use A; + public use A as A; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport2.chpl b/test/visibility/import/enablesUnqualified/useAndImport2.chpl index 160e0573d374..4ed113f19102 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport2.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport2.chpl @@ -11,7 +11,7 @@ module B { } module C { - public use A; + public use A as A; } module D { From 78ab7a4f52fac44ac18f493816c55887db7e90d1 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 12:47:08 -0500 Subject: [PATCH 50/96] Revert "Adjust tests in visibility/import to have public use" This reverts commit 1dc6fd783ddd09e1b884114c1f5bc6099905635b. Signed-off-by: Michael Ferguson --- test/visibility/import/useAndImport-useExcept1a.chpl | 2 +- test/visibility/import/useAndImport-useExcept1b.chpl | 2 +- test/visibility/import/useAndImport-useExcept1c.chpl | 2 +- test/visibility/import/useAndImport-useExcept1d.chpl | 2 +- test/visibility/import/useAndImport-useOnly1a.chpl | 2 +- test/visibility/import/useAndImport-useOnly1b.chpl | 2 +- test/visibility/import/useAndImport-useOnly1c.chpl | 2 +- test/visibility/import/useAndImport-useOnly1d.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing1a.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing1b.chpl | 2 +- test/visibility/import/useAndImport.chpl | 2 +- test/visibility/import/useAndImport2.chpl | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/visibility/import/useAndImport-useExcept1a.chpl b/test/visibility/import/useAndImport-useExcept1a.chpl index 4da639102fac..17d87576d695 100644 --- a/test/visibility/import/useAndImport-useExcept1a.chpl +++ b/test/visibility/import/useAndImport-useExcept1a.chpl @@ -12,7 +12,7 @@ module B { } module C { - public import A; + import A; } module D { diff --git a/test/visibility/import/useAndImport-useExcept1b.chpl b/test/visibility/import/useAndImport-useExcept1b.chpl index 24d269e53828..c8214da9aa56 100644 --- a/test/visibility/import/useAndImport-useExcept1b.chpl +++ b/test/visibility/import/useAndImport-useExcept1b.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public import A; + import A; } module C { diff --git a/test/visibility/import/useAndImport-useExcept1c.chpl b/test/visibility/import/useAndImport-useExcept1c.chpl index e8b6f6e0debd..4276742c02c8 100644 --- a/test/visibility/import/useAndImport-useExcept1c.chpl +++ b/test/visibility/import/useAndImport-useExcept1c.chpl @@ -12,7 +12,7 @@ module B { } module C { - public import A; + import A; } module D { diff --git a/test/visibility/import/useAndImport-useExcept1d.chpl b/test/visibility/import/useAndImport-useExcept1d.chpl index d7bb71c99fcf..570cbe9bb2b2 100644 --- a/test/visibility/import/useAndImport-useExcept1d.chpl +++ b/test/visibility/import/useAndImport-useExcept1d.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public import A; + import A; } module C { diff --git a/test/visibility/import/useAndImport-useOnly1a.chpl b/test/visibility/import/useAndImport-useOnly1a.chpl index 9ec7c73a7cdc..d13d045b1cff 100644 --- a/test/visibility/import/useAndImport-useOnly1a.chpl +++ b/test/visibility/import/useAndImport-useOnly1a.chpl @@ -12,7 +12,7 @@ module B { } module C { - public import A; + import A; } module D { diff --git a/test/visibility/import/useAndImport-useOnly1b.chpl b/test/visibility/import/useAndImport-useOnly1b.chpl index b4a27693bbcc..7b72fc9ca28d 100644 --- a/test/visibility/import/useAndImport-useOnly1b.chpl +++ b/test/visibility/import/useAndImport-useOnly1b.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public import A; + import A; } module C { diff --git a/test/visibility/import/useAndImport-useOnly1c.chpl b/test/visibility/import/useAndImport-useOnly1c.chpl index 669caa3cc296..0a41a6c3ac4f 100644 --- a/test/visibility/import/useAndImport-useOnly1c.chpl +++ b/test/visibility/import/useAndImport-useOnly1c.chpl @@ -12,7 +12,7 @@ module B { } module C { - public import A; + import A; } module D { diff --git a/test/visibility/import/useAndImport-useOnly1d.chpl b/test/visibility/import/useAndImport-useOnly1d.chpl index f84336cc4aa4..1b93876d7ddd 100644 --- a/test/visibility/import/useAndImport-useOnly1d.chpl +++ b/test/visibility/import/useAndImport-useOnly1d.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public import A; + import A; } module C { diff --git a/test/visibility/import/useAndImport-useOnlyNothing1a.chpl b/test/visibility/import/useAndImport-useOnlyNothing1a.chpl index 465c5c4ee21c..ada97107c983 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1a.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing1a.chpl @@ -12,7 +12,7 @@ module B { } module C { - public import A; + import A; } module D { diff --git a/test/visibility/import/useAndImport-useOnlyNothing1b.chpl b/test/visibility/import/useAndImport-useOnlyNothing1b.chpl index 60c9da23b887..5ed5dc0c4a5c 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1b.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing1b.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public import A; + import A; } module C { diff --git a/test/visibility/import/useAndImport.chpl b/test/visibility/import/useAndImport.chpl index 72dbb48013ad..22a2618c6ef9 100644 --- a/test/visibility/import/useAndImport.chpl +++ b/test/visibility/import/useAndImport.chpl @@ -10,7 +10,7 @@ module B { } module C { - public import A; + import A; } module D { diff --git a/test/visibility/import/useAndImport2.chpl b/test/visibility/import/useAndImport2.chpl index 4b5e8d9fea8c..73dc67a87979 100644 --- a/test/visibility/import/useAndImport2.chpl +++ b/test/visibility/import/useAndImport2.chpl @@ -6,7 +6,7 @@ module A { } } module B { - public import A; + import A; } module C { From 38f5ca66c5d65ccb686ad2ae2b504068a6beb776 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 12:49:34 -0500 Subject: [PATCH 51/96] Update .good files with errors For change for public use M not bringing in M --- Signed-off-by: Michael Ferguson --- test/visibility/import/useAndImport-useExcept1a.good | 5 ++--- test/visibility/import/useAndImport-useExcept1b.good | 5 ++--- test/visibility/import/useAndImport-useExcept1c.good | 5 ++--- test/visibility/import/useAndImport-useExcept1d.good | 5 ++--- test/visibility/import/useAndImport-useOnly1a.good | 5 ++--- test/visibility/import/useAndImport-useOnly1b.good | 5 ++--- test/visibility/import/useAndImport-useOnly1c.good | 5 ++--- test/visibility/import/useAndImport-useOnly1d.good | 5 ++--- test/visibility/import/useAndImport-useOnlyNothing1a.good | 4 ++-- test/visibility/import/useAndImport-useOnlyNothing1b.good | 4 ++-- 10 files changed, 20 insertions(+), 28 deletions(-) diff --git a/test/visibility/import/useAndImport-useExcept1a.good b/test/visibility/import/useAndImport-useExcept1a.good index fe87583de0ba..568c5a22ec32 100644 --- a/test/visibility/import/useAndImport-useExcept1a.good +++ b/test/visibility/import/useAndImport-useExcept1a.good @@ -1,3 +1,2 @@ -4 -In A.foo() -In A.foo() +useAndImport-useExcept1a.chpl:21: In function 'main': +useAndImport-useExcept1a.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useExcept1b.good b/test/visibility/import/useAndImport-useExcept1b.good index fe87583de0ba..346c345c3bd3 100644 --- a/test/visibility/import/useAndImport-useExcept1b.good +++ b/test/visibility/import/useAndImport-useExcept1b.good @@ -1,3 +1,2 @@ -4 -In A.foo() -In A.foo() +useAndImport-useExcept1b.chpl:21: In function 'main': +useAndImport-useExcept1b.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useExcept1c.good b/test/visibility/import/useAndImport-useExcept1c.good index 986d83f3aea0..218aa9684f21 100644 --- a/test/visibility/import/useAndImport-useExcept1c.good +++ b/test/visibility/import/useAndImport-useExcept1c.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useExcept1c.chpl:21: In function 'main': +useAndImport-useExcept1c.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useExcept1d.good b/test/visibility/import/useAndImport-useExcept1d.good index 986d83f3aea0..db76d2dbca3d 100644 --- a/test/visibility/import/useAndImport-useExcept1d.good +++ b/test/visibility/import/useAndImport-useExcept1d.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useExcept1d.chpl:21: In function 'main': +useAndImport-useExcept1d.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnly1a.good b/test/visibility/import/useAndImport-useOnly1a.good index fe87583de0ba..3c5c2734ef72 100644 --- a/test/visibility/import/useAndImport-useOnly1a.good +++ b/test/visibility/import/useAndImport-useOnly1a.good @@ -1,3 +1,2 @@ -4 -In A.foo() -In A.foo() +useAndImport-useOnly1a.chpl:21: In function 'main': +useAndImport-useOnly1a.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnly1b.good b/test/visibility/import/useAndImport-useOnly1b.good index fe87583de0ba..da4e79401d19 100644 --- a/test/visibility/import/useAndImport-useOnly1b.good +++ b/test/visibility/import/useAndImport-useOnly1b.good @@ -1,3 +1,2 @@ -4 -In A.foo() -In A.foo() +useAndImport-useOnly1b.chpl:21: In function 'main': +useAndImport-useOnly1b.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnly1c.good b/test/visibility/import/useAndImport-useOnly1c.good index 986d83f3aea0..cdeb582f7283 100644 --- a/test/visibility/import/useAndImport-useOnly1c.good +++ b/test/visibility/import/useAndImport-useOnly1c.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useOnly1c.chpl:21: In function 'main': +useAndImport-useOnly1c.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnly1d.good b/test/visibility/import/useAndImport-useOnly1d.good index 986d83f3aea0..d6adb8c82d9d 100644 --- a/test/visibility/import/useAndImport-useOnly1d.good +++ b/test/visibility/import/useAndImport-useOnly1d.good @@ -1,3 +1,2 @@ -4 -4 -In A.foo() +useAndImport-useOnly1d.chpl:21: In function 'main': +useAndImport-useOnly1d.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnlyNothing1a.good b/test/visibility/import/useAndImport-useOnlyNothing1a.good index ec220522d392..beb1cb6fd6a1 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1a.good +++ b/test/visibility/import/useAndImport-useOnlyNothing1a.good @@ -1,2 +1,2 @@ -4 -In A.foo() +useAndImport-useOnlyNothing1a.chpl:21: In function 'main': +useAndImport-useOnlyNothing1a.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnlyNothing1b.good b/test/visibility/import/useAndImport-useOnlyNothing1b.good index ec220522d392..dd77af82539f 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1b.good +++ b/test/visibility/import/useAndImport-useOnlyNothing1b.good @@ -1,2 +1,2 @@ -4 -In A.foo() +useAndImport-useOnlyNothing1b.chpl:21: In function 'main': +useAndImport-useOnlyNothing1b.chpl:23: error: 'A' undeclared (first use this function) From b5d224a2c4cb35ac2f62457593fd42fcc3d0ce70 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 14:45:25 -0500 Subject: [PATCH 52/96] Adjust onlyNothingField.chpl * put everything in a module to avoid a warning since the warning doesn't have anything to do with the apparent goal of this test * do 'public use Other' followed by 'use Other' as a way to get both qualified and unqualified access within that module --- Signed-off-by: Michael Ferguson --- test/visibility/empty/onlyNothingField.chpl | 13 ++++++++----- test/visibility/empty/onlyNothingField.good | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/visibility/empty/onlyNothingField.chpl b/test/visibility/empty/onlyNothingField.chpl index ee5d8425a2e9..8e0edb7b4eae 100644 --- a/test/visibility/empty/onlyNothingField.chpl +++ b/test/visibility/empty/onlyNothingField.chpl @@ -1,13 +1,16 @@ -proc main() { - use bash only; +module Program { + proc main() { + use bash only; - var p = bash.ls(); + var p = bash.ls(); - writeln(p.x); + writeln(p.x); + } } module bash { - public use super.Other; + public use Other; // does not bring in Other + use Other; // does bring in Other but only for local use proc ls(args='') { var p = Other.makeFoo(); diff --git a/test/visibility/empty/onlyNothingField.good b/test/visibility/empty/onlyNothingField.good index 1f320885ccec..27ba77ddaf61 100644 --- a/test/visibility/empty/onlyNothingField.good +++ b/test/visibility/empty/onlyNothingField.good @@ -1,2 +1 @@ -onlyNothingField.chpl:1: warning: This file-scope code is outside of any explicit module declarations (e.g., module Other), so an implicit module named 'onlyNothingField' is being introduced to contain the file's contents. true From 3de539d59e40bf425bf9cf64a01ee72586f8b219 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 14:46:40 -0500 Subject: [PATCH 53/96] Import FFTW in addition to public using it --- Signed-off-by: Michael Ferguson --- test/npb/ft/npadmana/DistributedFFT.chpl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/npb/ft/npadmana/DistributedFFT.chpl b/test/npb/ft/npadmana/DistributedFFT.chpl index 3679ef1847d0..a378768f427a 100644 --- a/test/npb/ft/npadmana/DistributedFFT.chpl +++ b/test/npb/ft/npadmana/DistributedFFT.chpl @@ -36,6 +36,7 @@ prototype module DistributedFFT { public use BlockDist; public use FFTW; + import FFTW; // also allow FFTW.execute, etc use AllLocalesBarriers; use RangeChunk; From 92c37e81f3e347f65d220f4c0c8b8eca3e193c6a Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 14:47:17 -0500 Subject: [PATCH 54/96] Adjust ChapelStandard to public use X as X rather than importing everything, which is more wordy. One odd thing about this change is that it changes the behavior of test/modules/bradc/userInsteadOfStandard/foo2.chpl. --- Signed-off-by: Michael Ferguson --- modules/internal/ChapelStandard.chpl | 126 +++++++++------------------ 1 file changed, 42 insertions(+), 84 deletions(-) diff --git a/modules/internal/ChapelStandard.chpl b/modules/internal/ChapelStandard.chpl index 820d4a06cdd4..60d0f425882a 100644 --- a/modules/internal/ChapelStandard.chpl +++ b/modules/internal/ChapelStandard.chpl @@ -26,93 +26,51 @@ module ChapelStandard { // Internal, but uses standard/CommDiagnostics // Internal modules. - public import CString; - public use CString; - public import Bytes; - public use Bytes; - public import String; - public use String; - public import OwnedObject; - public use OwnedObject; - public import SharedObject; - public use SharedObject; - public import ChapelEnv; - public use ChapelEnv; - public import ChapelBase; - public use ChapelBase; - public import Atomics; - public use Atomics; - public import NetworkAtomics; - public use NetworkAtomics; - public import NetworkAtomicTypes; - public use NetworkAtomicTypes; - public import AtomicsCommon; - public use AtomicsCommon; - public import ChapelIteratorSupport; - public use ChapelIteratorSupport; - public import ChapelThreads; - public use ChapelThreads; - public import ChapelTuple; - public use ChapelTuple; - public import ChapelRange; - public use ChapelRange; - public import ChapelReduce; - public use ChapelReduce; - public import ChapelSyncvar; - public use ChapelSyncvar; - public import ChapelTaskDataHelp; - public use ChapelTaskDataHelp; + public use CString as CString; + public use Bytes as Bytes; + public use String as String; + public use OwnedObject as OwnedObject; + public use SharedObject as SharedObject; + public use ChapelEnv as ChapelEnv; + public use ChapelBase as ChapelBase; + public use Atomics as Atomics; + public use NetworkAtomics as NetworkAtomics; + public use NetworkAtomicTypes as NetworkAtomicTypes; + public use AtomicsCommon as AtomicsCommon; + public use ChapelIteratorSupport as ChapelIteratorSupport; + public use ChapelThreads as ChapelThreads; + public use ChapelTuple as ChapelTuple; + public use ChapelRange as ChapelRange; + public use ChapelReduce as ChapelReduce; + public use ChapelSyncvar as ChapelSyncvar; + public use ChapelTaskDataHelp as ChapelTaskDataHelp; public use LocaleModel as _; // let LocaleModel refer to the class - public import ChapelLocale; - public use ChapelLocale; - public import ChapelPrivatization; - public use ChapelPrivatization; - public import DefaultRectangular; // This might be able to go just after Atomics - public use DefaultRectangular; // This might be able to go just after Atomics - public import LocalesArray; - public use LocalesArray; - public import ChapelArray; - public use ChapelArray; - public import ChapelDistribution; - public use ChapelDistribution; - public import ChapelAutoLocalAccess; - public use ChapelAutoLocalAccess; - public import ChapelIO; - public use ChapelIO; - public import LocaleTree; - public use LocaleTree; - public import ChapelHashing; - public use ChapelHashing; - public import DefaultAssociative; - public use DefaultAssociative; - public import DefaultSparse; - public use DefaultSparse; - public import ChapelTaskID; - public use ChapelTaskID; - public import ChapelTaskTable; - public use ChapelTaskTable; - public import MemTracking; - public use MemTracking; - public import ChapelUtil; - public use ChapelUtil; - public import Errors; - public use Errors; - public import ChapelTaskData; - public use ChapelTaskData; - public import ChapelSerializedBroadcast; - public use ChapelSerializedBroadcast; - public import ExportWrappers; - public use ExportWrappers; - public import ChapelAutoAggregation; - public use ChapelAutoAggregation; + public use ChapelLocale as ChapelLocale; + public use ChapelPrivatization as ChapelPrivatization; + public use DefaultRectangular as DefaultRectangular; // This might be able to go just after Atomics + public use LocalesArray as LocalesArray; + public use ChapelArray as ChapelArray; + public use ChapelDistribution as ChapelDistribution; + public use ChapelAutoLocalAccess as ChapelAutoLocalAccess; + public use ChapelIO as ChapelIO; + public use LocaleTree as LocaleTree; + public use ChapelHashing as ChapelHashing; + public use DefaultAssociative as DefaultAssociative; + public use DefaultSparse as DefaultSparse; + public use ChapelTaskID as ChapelTaskID; + public use ChapelTaskTable as ChapelTaskTable; + public use MemTracking as MemTracking; + public use ChapelUtil as ChapelUtil; + public use Errors as Errors; + public use ChapelTaskData as ChapelTaskData; + public use ChapelSerializedBroadcast as ChapelSerializedBroadcast; + public use ExportWrappers as ExportWrappers; + public use ChapelAutoAggregation as ChapelAutoAggregation; // Standard modules. - public import Types; - public use Types; - public import Math; - public use Math; - public import VectorizingIterator; - public use VectorizingIterator; + public use Types as Types; + public use Math as Math; + public use VectorizingIterator as VectorizingIterator; use stopInitCommDiags; // Internal, but uses standard/CommDiagnostics } From 3297bf1e245aa66fd69a9b29ac875dd09c2e08c8 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 17:12:43 -0500 Subject: [PATCH 55/96] Add test cases from issue #19352 --- Signed-off-by: Michael Ferguson --- test/modules/shadowing/issue-19352-1.chpl | 23 +++++++++++++++++++ test/modules/shadowing/issue-19352-1.good | 4 ++++ test/modules/shadowing/issue-19352-2a.chpl | 18 +++++++++++++++ test/modules/shadowing/issue-19352-2a.good | 4 ++++ test/modules/shadowing/issue-19352-2b.chpl | 18 +++++++++++++++ test/modules/shadowing/issue-19352-2b.good | 4 ++++ test/modules/shadowing/issue-19352-3.chpl | 26 ++++++++++++++++++++++ test/modules/shadowing/issue-19352-3.good | 4 ++++ 8 files changed, 101 insertions(+) create mode 100644 test/modules/shadowing/issue-19352-1.chpl create mode 100644 test/modules/shadowing/issue-19352-1.good create mode 100644 test/modules/shadowing/issue-19352-2a.chpl create mode 100644 test/modules/shadowing/issue-19352-2a.good create mode 100644 test/modules/shadowing/issue-19352-2b.chpl create mode 100644 test/modules/shadowing/issue-19352-2b.good create mode 100644 test/modules/shadowing/issue-19352-3.chpl create mode 100644 test/modules/shadowing/issue-19352-3.good diff --git a/test/modules/shadowing/issue-19352-1.chpl b/test/modules/shadowing/issue-19352-1.chpl new file mode 100644 index 000000000000..103956afe6ca --- /dev/null +++ b/test/modules/shadowing/issue-19352-1.chpl @@ -0,0 +1,23 @@ +module Library { + record rec { + proc method() { writeln("Library's rec.method()"); } + } +} + + +module LibraryPlus { + import Library; + import Library.rec; + + proc rec.method() { writeln("LibraryPlus's rec.method()"); } +} + +// Case 1 +module Program { + import Library; + proc main() { + import LibraryPlus.rec; // does this make LibraryPlus.rec.method "closer" ? + var r = new Library.rec(); + r.method(); // currently: ambiguity error + } +} diff --git a/test/modules/shadowing/issue-19352-1.good b/test/modules/shadowing/issue-19352-1.good new file mode 100644 index 000000000000..b6941d112d6d --- /dev/null +++ b/test/modules/shadowing/issue-19352-1.good @@ -0,0 +1,4 @@ +issue-19352-1.chpl:18: In function 'main': +issue-19352-1.chpl:21: error: ambiguous call 'rec.method()' +issue-19352-1.chpl:3: note: candidates are: rec.method() +issue-19352-1.chpl:12: note: rec.method() diff --git a/test/modules/shadowing/issue-19352-2a.chpl b/test/modules/shadowing/issue-19352-2a.chpl new file mode 100644 index 000000000000..ecd53cf031ce --- /dev/null +++ b/test/modules/shadowing/issue-19352-2a.chpl @@ -0,0 +1,18 @@ +module Library { + record rec { + proc method() { writeln("Library's rec.method()"); } + } +} + +// Case 2a +module Program { + import Library; + import Library.rec; // Should this bring in the methods as if defined here? + + proc rec.method() { writeln("Program's rec.method()"); } + + proc main() { + var r = new Library.rec(); + r.method(); // currently outputs: Program's rec.method() + } +} diff --git a/test/modules/shadowing/issue-19352-2a.good b/test/modules/shadowing/issue-19352-2a.good new file mode 100644 index 000000000000..d4387cdd1d01 --- /dev/null +++ b/test/modules/shadowing/issue-19352-2a.good @@ -0,0 +1,4 @@ +issue-19352-2a.chpl:14: In function 'main': +issue-19352-2a.chpl:16: error: ambiguous call 'rec.method()' +issue-19352-2a.chpl:3: note: candidates are: rec.method() +issue-19352-2a.chpl:12: note: rec.method() diff --git a/test/modules/shadowing/issue-19352-2b.chpl b/test/modules/shadowing/issue-19352-2b.chpl new file mode 100644 index 000000000000..aad951313a39 --- /dev/null +++ b/test/modules/shadowing/issue-19352-2b.chpl @@ -0,0 +1,18 @@ +module Library { + record rec { + proc method() { writeln("Library's rec.method()"); } + } +} + +// Case 2b +module Program { + import Library; // Should this bring in the methods + // on types defined in Library as if defined here? + + proc (Library.rec).method() { writeln("Program's rec.method()"); } + + proc main() { + var r = new Library.rec(); + r.method(); // currently outputs: Program's rec.method() + } +} diff --git a/test/modules/shadowing/issue-19352-2b.good b/test/modules/shadowing/issue-19352-2b.good new file mode 100644 index 000000000000..edb96c24ed0a --- /dev/null +++ b/test/modules/shadowing/issue-19352-2b.good @@ -0,0 +1,4 @@ +issue-19352-2b.chpl:14: In function 'main': +issue-19352-2b.chpl:16: error: ambiguous call 'rec.method()' +issue-19352-2b.chpl:3: note: candidates are: rec.method() +issue-19352-2b.chpl:12: note: (Library.rec).method() diff --git a/test/modules/shadowing/issue-19352-3.chpl b/test/modules/shadowing/issue-19352-3.chpl new file mode 100644 index 000000000000..17c853190ec6 --- /dev/null +++ b/test/modules/shadowing/issue-19352-3.chpl @@ -0,0 +1,26 @@ +module Library { + record rec { + proc method() { writeln("Library's rec.method()"); } + } +} + + +module LibraryPlus { + import Library; + import Library.rec; + + proc rec.method() { writeln("LibraryPlus's rec.method()"); } +} + +// Case 3 +module Program { + public import Library; + public use LibraryPlus; // should LibraryPlus.rec.method now shadow Library.rec.method? + + proc main() { + var r = new Library.rec(); + r.method(); // currently: + // without PR #19306, ambiguity error + // with PR #19306, outputs LibraryPlus's rec.method() + } +} diff --git a/test/modules/shadowing/issue-19352-3.good b/test/modules/shadowing/issue-19352-3.good new file mode 100644 index 000000000000..d392042a29fb --- /dev/null +++ b/test/modules/shadowing/issue-19352-3.good @@ -0,0 +1,4 @@ +issue-19352-3.chpl:20: In function 'main': +issue-19352-3.chpl:22: error: ambiguous call 'rec.method()' +issue-19352-3.chpl:3: note: candidates are: rec.method() +issue-19352-3.chpl:12: note: rec.method() From bc6808dc5e64fa78a9ebf7e0a4f5eed34d90f0fe Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 8 Mar 2022 17:13:01 -0500 Subject: [PATCH 56/96] Try having methods never shadow in fn disambiguation --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index f5bd4f5573f8..ec0a351545f5 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -1960,6 +1960,10 @@ isMoreVisibleInternal(BlockStmt* block, FnSymbol* fn1, FnSymbol* fn2, // static MoreVisibleResult isMoreVisible(Expr* expr, FnSymbol* fn1, FnSymbol* fn2) { + // Do not consider methods more visible in disambiguation + if (fn1->isMethod() || fn2->isMethod()) + return FOUND_NEITHER; + // // common-case check to see if functions have equal visibility // From 6602699d83ff7cf4579896764c9ad6d843146966 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 11:35:07 -0400 Subject: [PATCH 57/96] Remove redundant proc rank from DimensionalArr For test/chplvis/benchmarks-hpcc/hpl-vdb.chpl See also #19474. --- Signed-off-by: Michael Ferguson --- modules/dists/DimensionalDist2D.chpl | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/dists/DimensionalDist2D.chpl b/modules/dists/DimensionalDist2D.chpl index f5aa9c186f34..4ae4538265c0 100644 --- a/modules/dists/DimensionalDist2D.chpl +++ b/modules/dists/DimensionalDist2D.chpl @@ -358,7 +358,6 @@ class DimensionalArr : BaseRectangularArr { // same as 'dom'; for an alias (e.g. a slice), 'dom' of the original array const allocDom: dom.type; // must be a DimensionalDom - proc rank param return dom.rank; proc targetIds return localAdescs.domain; // no subordinate 1-d array descriptors - we handle storage ourselves From a37bce469b9bcd0eaed9166f43d58a34b4dc3cc6 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 14:01:58 -0400 Subject: [PATCH 58/96] Put breakList.good back Now that shadowing is not considered for methods --- Signed-off-by: Michael Ferguson --- test/classes/diten/breakList.good | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/classes/diten/breakList.good b/test/classes/diten/breakList.good index 3caa3f510058..2d18c58c117b 100644 --- a/test/classes/diten/breakList.good +++ b/test/classes/diten/breakList.good @@ -1,2 +1,7 @@ -3.0 4.0 -breakList.chpl:7: error: halt reached - I Got you! +breakList.chpl:23: In function 'bar': +breakList.chpl:26: error: multiple overload sets are applicable to this call +breakList.chpl:6: note: the best-matching candidate is here +breakList.chpl:3: note: ... defined in this module +$CHPL_HOME/modules/packages/LinkedLists.chpl:nnnn: note: even though the candidate here is also available +$CHPL_HOME/modules/packages/LinkedLists.chpl:nnnn: note: ... defined in this module +breakList.chpl:26: note: use --no-overload-sets-checks to disable overload sets errors From 07f7b12c127072f5ec964dc1bd11e8a2192707df Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 14:19:34 -0400 Subject: [PATCH 59/96] Update .good for ambiguity This is effectively Case 2 in #19352. --- Signed-off-by: Michael Ferguson --- .../lydia/resolution-nested-method-outer-module.good | 8 ++++---- test/classes/lydia/resolution-nested-method.good | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/classes/lydia/resolution-nested-method-outer-module.good b/test/classes/lydia/resolution-nested-method-outer-module.good index 4344358a4024..354b02e42bca 100644 --- a/test/classes/lydia/resolution-nested-method-outer-module.good +++ b/test/classes/lydia/resolution-nested-method-outer-module.good @@ -1,4 +1,4 @@ -foo unmodified -Modified foo -Modified foo -foo unmodified +resolution-nested-method-outer-module.chpl:12: In function 'modifyIt': +resolution-nested-method-outer-module.chpl:17: error: ambiguous call 'foo.bar()' +resolution-nested-method-outer-module.chpl:5: note: candidates are: foo.bar() +resolution-nested-method-outer-module.chpl:18: note: foo.bar() diff --git a/test/classes/lydia/resolution-nested-method.good b/test/classes/lydia/resolution-nested-method.good index 4344358a4024..4e1d428ae56e 100644 --- a/test/classes/lydia/resolution-nested-method.good +++ b/test/classes/lydia/resolution-nested-method.good @@ -1,4 +1,4 @@ -foo unmodified -Modified foo -Modified foo -foo unmodified +resolution-nested-method.chpl:10: In function 'modifyIt': +resolution-nested-method.chpl:14: error: ambiguous call 'foo.bar()' +resolution-nested-method.chpl:5: note: candidates are: foo.bar() +resolution-nested-method.chpl:15: note: foo.bar() From f5c7b1827e597e45db645948152bef1878e198fa Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 14:21:12 -0400 Subject: [PATCH 60/96] Update Application8.good to be ambiguity --- Signed-off-by: Michael Ferguson --- test/functions/ferguson/hijacking/Application8.good | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/functions/ferguson/hijacking/Application8.good b/test/functions/ferguson/hijacking/Application8.good index ff238b21cc44..bc7e23c85cd6 100644 --- a/test/functions/ferguson/hijacking/Application8.good +++ b/test/functions/ferguson/hijacking/Application8.good @@ -1 +1,4 @@ -In Application.Widget.foo +Application8.chpl:17: In function 'main': +Application8.chpl:20: error: ambiguous call 'Widget.run(int(64))' +Application8.chpl:12: note: candidates are: Widget.run(x: real) +Application8.chpl:3: note: Base.run(x: int) From 8bf282e764fccb239aed4613ec3cd07028b73a5b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 15:08:04 -0400 Subject: [PATCH 61/96] Split check-gc-reuse-funmets into test of fns and methods --- Signed-off-by: Michael Ferguson --- .../generic/poi/check-gc-reuse-funmets.good | 97 ------------- .../generic/poi/check-gc-reuse-funs.chpl | 130 ++++++++++++++++++ .../generic/poi/check-gc-reuse-funs.good | 73 ++++++++++ ...nmets.chpl => check-gc-reuse-methods.chpl} | 3 +- .../generic/poi/check-gc-reuse-methods.good | 97 +++++++++++++ 5 files changed, 302 insertions(+), 98 deletions(-) delete mode 100644 test/functions/generic/poi/check-gc-reuse-funmets.good create mode 100644 test/functions/generic/poi/check-gc-reuse-funs.chpl create mode 100644 test/functions/generic/poi/check-gc-reuse-funs.good rename test/functions/generic/poi/{check-gc-reuse-funmets.chpl => check-gc-reuse-methods.chpl} (96%) create mode 100644 test/functions/generic/poi/check-gc-reuse-methods.good diff --git a/test/functions/generic/poi/check-gc-reuse-funmets.good b/test/functions/generic/poi/check-gc-reuse-funmets.good deleted file mode 100644 index 812e56a0578c..000000000000 --- a/test/functions/generic/poi/check-gc-reuse-funmets.good +++ /dev/null @@ -1,97 +0,0 @@ -check-gc-reuse-funmets.chpl:31: In function 'u1': -check-gc-reuse-funmets.chpl:32: warning: User.u1 -check-gc-reuse-funmets.chpl:16: In function 'libFun': -check-gc-reuse-funmets.chpl:17: warning: User.workFun -check-gc-reuse-funmets.chpl:18: warning: User.workMet - check-gc-reuse-funmets.chpl:33: called as libFun(myArg: owned MyClass) -check-gc-reuse-funmets.chpl:20: In method 'libMet': -check-gc-reuse-funmets.chpl:21: warning: User.workFun -check-gc-reuse-funmets.chpl:22: warning: User.workMet - check-gc-reuse-funmets.chpl:34: called as MyClass.libMet(myArg: owned MyClass) -check-gc-reuse-funmets.chpl:36: In function 'u2': -check-gc-reuse-funmets.chpl:38: warning: User.u2 -check-gc-reuse-funmets.chpl:43: In function 'u3': -check-gc-reuse-funmets.chpl:46: warning: User.u3 -check-gc-reuse-funmets.chpl:16: In function 'libFun': -check-gc-reuse-funmets.chpl:17: warning: User.u3.workFun -check-gc-reuse-funmets.chpl:18: warning: User.u3.workMet - check-gc-reuse-funmets.chpl:47: called as libFun(myArg: owned MyClass) -check-gc-reuse-funmets.chpl:20: In method 'libMet': -check-gc-reuse-funmets.chpl:21: warning: User.u3.workFun -check-gc-reuse-funmets.chpl:22: warning: User.u3.workMet - check-gc-reuse-funmets.chpl:48: called as MyClass.libMet(myArg: owned MyClass) -check-gc-reuse-funmets.chpl:81: In function 'm1con': -check-gc-reuse-funmets.chpl:82: warning: More1.m1con -check-gc-reuse-funmets.chpl:16: In function 'libFun': -check-gc-reuse-funmets.chpl:17: warning: More1.workFun -check-gc-reuse-funmets.chpl:18: warning: More1.workMet - check-gc-reuse-funmets.chpl:83: called as libFun(myArg: owned MyClass) -check-gc-reuse-funmets.chpl:20: In method 'libMet': -check-gc-reuse-funmets.chpl:21: warning: More1.workFun -check-gc-reuse-funmets.chpl:22: warning: More1.workMet - check-gc-reuse-funmets.chpl:84: called as MyClass.libMet(myArg: owned MyClass) -check-gc-reuse-funmets.chpl:86: In function 'm1gen': -check-gc-reuse-funmets.chpl:87: warning: More1.m1gen - check-gc-reuse-funmets.chpl:58: called as m1gen(param p = 0) -check-gc-reuse-funmets.chpl:96: In function 'm2con': -check-gc-reuse-funmets.chpl:97: warning: More2.m2con -check-gc-reuse-funmets.chpl:101: In function 'm2gen': -check-gc-reuse-funmets.chpl:102: warning: More2.m2gen - check-gc-reuse-funmets.chpl:63: called as m2gen(param p = 0) -check-gc-reuse-funmets.chpl:127: In function 'combo2a': -check-gc-reuse-funmets.chpl:128: warning: Combo2.combo2a - check-gc-reuse-funmets.chpl:115: called as combo2a(param p = 0) -check-gc-reuse-funmets.chpl:16: In function 'libFun': -check-gc-reuse-funmets.chpl:17: warning: Combo1.workFun -check-gc-reuse-funmets.chpl:18: warning: Combo1.workMet - check-gc-reuse-funmets.chpl:129: called as libFun(myArg: owned MyClass) from function 'combo2a' - check-gc-reuse-funmets.chpl:115: called as combo2a(param p = 0) -check-gc-reuse-funmets.chpl:20: In method 'libMet': -check-gc-reuse-funmets.chpl:21: warning: Combo1.workFun -check-gc-reuse-funmets.chpl:22: warning: Combo1.workMet - check-gc-reuse-funmets.chpl:130: called as MyClass.libMet(myArg: owned MyClass) from function 'combo2a' - check-gc-reuse-funmets.chpl:115: called as combo2a(param p = 0) -check-gc-reuse-funmets.chpl:117: In function 'combo1b': -check-gc-reuse-funmets.chpl:118: warning: Combo1.combo1b - check-gc-reuse-funmets.chpl:134: called as combo1b(param p = 0) -User.u1 -User.workFun -User.workMet -User.workFun -User.workMet -User.u2 -User.workFun -User.workMet -User.workFun -User.workMet -User.u3 -User.u3.workFun -User.u3.workMet -User.u3.workFun -User.u3.workMet -More1.m1con -More1.workFun -More1.workMet -More1.workFun -More1.workMet -More1.m1gen -More1.workFun -More1.workMet -More1.workFun -More1.workMet -More2.m2con -More2.m2gen -User.workFun -User.workMet -User.workFun -User.workMet -Combo2.combo2a -Combo1.workFun -Combo1.workMet -Combo1.workFun -Combo1.workMet -Combo1.combo1b -Combo1.workFun -Combo1.workMet -Combo1.workFun -Combo1.workMet diff --git a/test/functions/generic/poi/check-gc-reuse-funs.chpl b/test/functions/generic/poi/check-gc-reuse-funs.chpl new file mode 100644 index 000000000000..e6b4bbb8f18d --- /dev/null +++ b/test/functions/generic/poi/check-gc-reuse-funs.chpl @@ -0,0 +1,130 @@ +// Ensure generic-instantiations cache entries for 'libFun' and 'libMet' +// are not reused when reuse would be incorrect. + + + + +module Lib { + class MyClass { } + var myC = new MyClass(); + proc note(param message, param depth) { + compilerWarning(message, depth); + writeln(message); + } + + // these invoke workFun through POI + proc libFun(myArg) { + workFun(); + } + proc MyClass.libMet(myArg) { + workFun(); + } +} + +module User { + use Lib; + proc workFun() { note("User.workFun", 2); } + + proc u1() { + note("User.u1", 1); + libFun(myC); // create a cache entry + myC.libMet(myC); // ditto + } + proc u2() { + { + note("User.u2", 1); + libFun(myC); // reuse the cache entry + myC.libMet(myC); + } + } + proc u3() { + proc workFun() { note("User.u3.workFun", 2); } + note("User.u3", 1); + libFun(myC); // cannot reuse the cache entry -> create a new one + myC.libMet(myC); + } + + proc main { + u1(); + u2(); + u3(); + { + use More1; + m1con(); + m1gen(0); + } + { + use More2; + m2con(); + m2gen(0); + } + { + use Combo1; + combo1a(); + } + { + use Combo2; + combo2b(); + } + } +} + +module More1 { + use Lib; + proc workFun() { note("More1.workFun", 2); } + + proc m1con() { + note("More1.m1con", 1); + libFun(myC); // cannot reuse the cache entry -> create a new one + myC.libMet(myC); + } + proc m1gen(param p) { + note("More1.m1gen", 1); + libFun(myC); // can reuse the cache entry created for m1con + myC.libMet(myC); + } +} + +module More2 { + use Lib; + + proc m2con() { + note("More2.m2con", 1); + // libFun(myC); // error: no visible workFun/Met() + // myC.libMet(myC); + } + proc m2gen(param p) { + note("More2.m2gen", 1); + libFun(myC); // can reuse the cache entry created for u1 + myC.libMet(myC); + } +} + +module Combo1 { + use Lib; + proc workFun() { note("Combo1.workFun", 2); } + + proc combo1a() { + use Combo2; + combo2a(0); + } + proc combo1b(param p) { + note("Combo1.combo1b", 1); + libFun(myC); // can reuse the cache entry created + myC.libMet(myC); // for combo1a->combo2a + } +} + +module Combo2 { + use Lib; + + proc combo2a(param p) { + note("Combo2.combo2a", 1); + libFun(myC); // create a fresh cache entry + myC.libMet(myC); + } + proc combo2b() { + use Combo1; + combo1b(0); + } +} diff --git a/test/functions/generic/poi/check-gc-reuse-funs.good b/test/functions/generic/poi/check-gc-reuse-funs.good new file mode 100644 index 000000000000..ecafa7d4342c --- /dev/null +++ b/test/functions/generic/poi/check-gc-reuse-funs.good @@ -0,0 +1,73 @@ +check-gc-reuse-funs.chpl:28: In function 'u1': +check-gc-reuse-funs.chpl:29: warning: User.u1 +check-gc-reuse-funs.chpl:16: In function 'libFun': +check-gc-reuse-funs.chpl:17: warning: User.workFun + check-gc-reuse-funs.chpl:30: called as libFun(myArg: owned MyClass) +check-gc-reuse-funs.chpl:19: In method 'libMet': +check-gc-reuse-funs.chpl:20: warning: User.workFun + check-gc-reuse-funs.chpl:31: called as MyClass.libMet(myArg: owned MyClass) +check-gc-reuse-funs.chpl:33: In function 'u2': +check-gc-reuse-funs.chpl:35: warning: User.u2 +check-gc-reuse-funs.chpl:40: In function 'u3': +check-gc-reuse-funs.chpl:42: warning: User.u3 +check-gc-reuse-funs.chpl:16: In function 'libFun': +check-gc-reuse-funs.chpl:17: warning: User.u3.workFun + check-gc-reuse-funs.chpl:43: called as libFun(myArg: owned MyClass) +check-gc-reuse-funs.chpl:19: In method 'libMet': +check-gc-reuse-funs.chpl:20: warning: User.u3.workFun + check-gc-reuse-funs.chpl:44: called as MyClass.libMet(myArg: owned MyClass) +check-gc-reuse-funs.chpl:76: In function 'm1con': +check-gc-reuse-funs.chpl:77: warning: More1.m1con +check-gc-reuse-funs.chpl:16: In function 'libFun': +check-gc-reuse-funs.chpl:17: warning: More1.workFun + check-gc-reuse-funs.chpl:78: called as libFun(myArg: owned MyClass) +check-gc-reuse-funs.chpl:19: In method 'libMet': +check-gc-reuse-funs.chpl:20: warning: More1.workFun + check-gc-reuse-funs.chpl:79: called as MyClass.libMet(myArg: owned MyClass) +check-gc-reuse-funs.chpl:81: In function 'm1gen': +check-gc-reuse-funs.chpl:82: warning: More1.m1gen + check-gc-reuse-funs.chpl:54: called as m1gen(param p = 0) +check-gc-reuse-funs.chpl:91: In function 'm2con': +check-gc-reuse-funs.chpl:92: warning: More2.m2con +check-gc-reuse-funs.chpl:96: In function 'm2gen': +check-gc-reuse-funs.chpl:97: warning: More2.m2gen + check-gc-reuse-funs.chpl:59: called as m2gen(param p = 0) +check-gc-reuse-funs.chpl:121: In function 'combo2a': +check-gc-reuse-funs.chpl:122: warning: Combo2.combo2a + check-gc-reuse-funs.chpl:109: called as combo2a(param p = 0) +check-gc-reuse-funs.chpl:16: In function 'libFun': +check-gc-reuse-funs.chpl:17: warning: Combo1.workFun + check-gc-reuse-funs.chpl:123: called as libFun(myArg: owned MyClass) from function 'combo2a' + check-gc-reuse-funs.chpl:109: called as combo2a(param p = 0) +check-gc-reuse-funs.chpl:19: In method 'libMet': +check-gc-reuse-funs.chpl:20: warning: Combo1.workFun + check-gc-reuse-funs.chpl:124: called as MyClass.libMet(myArg: owned MyClass) from function 'combo2a' + check-gc-reuse-funs.chpl:109: called as combo2a(param p = 0) +check-gc-reuse-funs.chpl:111: In function 'combo1b': +check-gc-reuse-funs.chpl:112: warning: Combo1.combo1b + check-gc-reuse-funs.chpl:128: called as combo1b(param p = 0) +User.u1 +User.workFun +User.workFun +User.u2 +User.workFun +User.workFun +User.u3 +User.u3.workFun +User.u3.workFun +More1.m1con +More1.workFun +More1.workFun +More1.m1gen +More1.workFun +More1.workFun +More2.m2con +More2.m2gen +User.workFun +User.workFun +Combo2.combo2a +Combo1.workFun +Combo1.workFun +Combo1.combo1b +Combo1.workFun +Combo1.workFun diff --git a/test/functions/generic/poi/check-gc-reuse-funmets.chpl b/test/functions/generic/poi/check-gc-reuse-methods.chpl similarity index 96% rename from test/functions/generic/poi/check-gc-reuse-funmets.chpl rename to test/functions/generic/poi/check-gc-reuse-methods.chpl index 2066d4128ef2..3b0f63b1d3f7 100644 --- a/test/functions/generic/poi/check-gc-reuse-funmets.chpl +++ b/test/functions/generic/poi/check-gc-reuse-methods.chpl @@ -42,7 +42,8 @@ module User { } proc u3() { proc workFun() { note("User.u3.workFun", 2); } - proc MyClass.workMet() { note("User.u3.workMet", 2); } + // does not use a local proc MyClass.workMet b/c that would be ambiguous + // see #19352 note("User.u3", 1); libFun(myC); // cannot reuse the cache entry -> create a new one myC.libMet(myC); diff --git a/test/functions/generic/poi/check-gc-reuse-methods.good b/test/functions/generic/poi/check-gc-reuse-methods.good new file mode 100644 index 000000000000..dc0bff391929 --- /dev/null +++ b/test/functions/generic/poi/check-gc-reuse-methods.good @@ -0,0 +1,97 @@ +check-gc-reuse-methods.chpl:31: In function 'u1': +check-gc-reuse-methods.chpl:32: warning: User.u1 +check-gc-reuse-methods.chpl:16: In function 'libFun': +check-gc-reuse-methods.chpl:17: warning: User.workFun +check-gc-reuse-methods.chpl:18: warning: User.workMet + check-gc-reuse-methods.chpl:33: called as libFun(myArg: owned MyClass) +check-gc-reuse-methods.chpl:20: In method 'libMet': +check-gc-reuse-methods.chpl:21: warning: User.workFun +check-gc-reuse-methods.chpl:22: warning: User.workMet + check-gc-reuse-methods.chpl:34: called as MyClass.libMet(myArg: owned MyClass) +check-gc-reuse-methods.chpl:36: In function 'u2': +check-gc-reuse-methods.chpl:38: warning: User.u2 +check-gc-reuse-methods.chpl:43: In function 'u3': +check-gc-reuse-methods.chpl:47: warning: User.u3 +check-gc-reuse-methods.chpl:16: In function 'libFun': +check-gc-reuse-methods.chpl:17: warning: User.u3.workFun +check-gc-reuse-methods.chpl:18: warning: User.workMet + check-gc-reuse-methods.chpl:48: called as libFun(myArg: owned MyClass) +check-gc-reuse-methods.chpl:20: In method 'libMet': +check-gc-reuse-methods.chpl:21: warning: User.u3.workFun +check-gc-reuse-methods.chpl:22: warning: User.workMet + check-gc-reuse-methods.chpl:49: called as MyClass.libMet(myArg: owned MyClass) +check-gc-reuse-methods.chpl:82: In function 'm1con': +check-gc-reuse-methods.chpl:83: warning: More1.m1con +check-gc-reuse-methods.chpl:16: In function 'libFun': +check-gc-reuse-methods.chpl:17: warning: More1.workFun +check-gc-reuse-methods.chpl:18: warning: More1.workMet + check-gc-reuse-methods.chpl:84: called as libFun(myArg: owned MyClass) +check-gc-reuse-methods.chpl:20: In method 'libMet': +check-gc-reuse-methods.chpl:21: warning: More1.workFun +check-gc-reuse-methods.chpl:22: warning: More1.workMet + check-gc-reuse-methods.chpl:85: called as MyClass.libMet(myArg: owned MyClass) +check-gc-reuse-methods.chpl:87: In function 'm1gen': +check-gc-reuse-methods.chpl:88: warning: More1.m1gen + check-gc-reuse-methods.chpl:59: called as m1gen(param p = 0) +check-gc-reuse-methods.chpl:97: In function 'm2con': +check-gc-reuse-methods.chpl:98: warning: More2.m2con +check-gc-reuse-methods.chpl:102: In function 'm2gen': +check-gc-reuse-methods.chpl:103: warning: More2.m2gen + check-gc-reuse-methods.chpl:64: called as m2gen(param p = 0) +check-gc-reuse-methods.chpl:128: In function 'combo2a': +check-gc-reuse-methods.chpl:129: warning: Combo2.combo2a + check-gc-reuse-methods.chpl:116: called as combo2a(param p = 0) +check-gc-reuse-methods.chpl:16: In function 'libFun': +check-gc-reuse-methods.chpl:17: warning: Combo1.workFun +check-gc-reuse-methods.chpl:18: warning: Combo1.workMet + check-gc-reuse-methods.chpl:130: called as libFun(myArg: owned MyClass) from function 'combo2a' + check-gc-reuse-methods.chpl:116: called as combo2a(param p = 0) +check-gc-reuse-methods.chpl:20: In method 'libMet': +check-gc-reuse-methods.chpl:21: warning: Combo1.workFun +check-gc-reuse-methods.chpl:22: warning: Combo1.workMet + check-gc-reuse-methods.chpl:131: called as MyClass.libMet(myArg: owned MyClass) from function 'combo2a' + check-gc-reuse-methods.chpl:116: called as combo2a(param p = 0) +check-gc-reuse-methods.chpl:118: In function 'combo1b': +check-gc-reuse-methods.chpl:119: warning: Combo1.combo1b + check-gc-reuse-methods.chpl:135: called as combo1b(param p = 0) +User.u1 +User.workFun +User.workMet +User.workFun +User.workMet +User.u2 +User.workFun +User.workMet +User.workFun +User.workMet +User.u3 +User.u3.workFun +User.workMet +User.u3.workFun +User.workMet +More1.m1con +More1.workFun +More1.workMet +More1.workFun +More1.workMet +More1.m1gen +More1.workFun +More1.workMet +More1.workFun +More1.workMet +More2.m2con +More2.m2gen +User.workFun +User.workMet +User.workFun +User.workMet +Combo2.combo2a +Combo1.workFun +Combo1.workMet +Combo1.workFun +Combo1.workMet +Combo1.combo1b +Combo1.workFun +Combo1.workMet +Combo1.workFun +Combo1.workMet From 934865f44335a78d44887c66e9c7e7ebeb48dcb6 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 15:25:32 -0400 Subject: [PATCH 62/96] Avoid ambiguity for local method effectively Case 2 in #19352. --- Signed-off-by: Michael Ferguson --- .../generic/poi/check-gc-reuse-opers.chpl | 5 +- .../generic/poi/check-gc-reuse-opers.good | 95 +++++++++---------- 2 files changed, 48 insertions(+), 52 deletions(-) diff --git a/test/functions/generic/poi/check-gc-reuse-opers.chpl b/test/functions/generic/poi/check-gc-reuse-opers.chpl index 549f467f830d..af011a5f1db9 100644 --- a/test/functions/generic/poi/check-gc-reuse-opers.chpl +++ b/test/functions/generic/poi/check-gc-reuse-opers.chpl @@ -58,8 +58,9 @@ module User { } } proc u3() { - proc MyRecord.init(param p) { note("u3.init", 2); rp = 0; } - proc MyRecord.init=(other) { note("u3.init=", 2); rp = 0; } + // having these methods here would lead to ambiguity -- see #19352 + //proc MyRecord.init(param p) { note("u3.init", 2); rp = 0; } + //proc MyRecord.init=(other) { note("u3.init=", 2); rp = 0; } operator =(ref lhs:MyRecord, rhs:MyRecord) { note("u3.=", 2); } operator <(lhs:MyRecord, rhs:MyRecord) { note("u3.<", 2); return true; } diff --git a/test/functions/generic/poi/check-gc-reuse-opers.good b/test/functions/generic/poi/check-gc-reuse-opers.good index ed4fe7d6840a..52a5422d59e7 100644 --- a/test/functions/generic/poi/check-gc-reuse-opers.good +++ b/test/functions/generic/poi/check-gc-reuse-opers.good @@ -21,84 +21,79 @@ check-gc-reuse-opers.chpl:27: warning: User._castT check-gc-reuse-opers.chpl:49: In function 'u2': check-gc-reuse-opers.chpl:51: warning: User.u2 check-gc-reuse-opers.chpl:60: In function 'u3': -check-gc-reuse-opers.chpl:69: warning: User.u3 -check-gc-reuse-opers.chpl:23: In function 'libIE': -check-gc-reuse-opers.chpl:23: warning: u3.init= - check-gc-reuse-opers.chpl:71: called as libIE(myArg: int(64)) +check-gc-reuse-opers.chpl:70: warning: User.u3 check-gc-reuse-opers.chpl:24: In function 'libAS': check-gc-reuse-opers.chpl:24: warning: u3.= - check-gc-reuse-opers.chpl:72: called as libAS(myArg: int(64)) + check-gc-reuse-opers.chpl:73: called as libAS(myArg: int(64)) check-gc-reuse-opers.chpl:25: In function 'libLT': check-gc-reuse-opers.chpl:25: warning: u3.< - check-gc-reuse-opers.chpl:73: called as libLT(myArg: int(64)) + check-gc-reuse-opers.chpl:74: called as libLT(myArg: int(64)) check-gc-reuse-opers.chpl:26: In function 'libCF': check-gc-reuse-opers.chpl:26: warning: u3._castF - check-gc-reuse-opers.chpl:74: called as libCF(myArg: int(64)) + check-gc-reuse-opers.chpl:75: called as libCF(myArg: int(64)) check-gc-reuse-opers.chpl:27: In function 'libCT': check-gc-reuse-opers.chpl:27: warning: u3._castT - check-gc-reuse-opers.chpl:75: called as libCT(myArg: int(64)) -check-gc-reuse-opers.chpl:60: In function 'u3': -check-gc-reuse-opers.chpl:68: warning: u3.init -check-gc-reuse-opers.chpl:114: In function 'm1con': -check-gc-reuse-opers.chpl:115: warning: More1.m1con + check-gc-reuse-opers.chpl:76: called as libCT(myArg: int(64)) +check-gc-reuse-opers.chpl:115: In function 'm1con': +check-gc-reuse-opers.chpl:116: warning: More1.m1con check-gc-reuse-opers.chpl:23: In function 'libIE': check-gc-reuse-opers.chpl:23: warning: More1.init= - check-gc-reuse-opers.chpl:117: called as libIE(myArg: int(64)) + check-gc-reuse-opers.chpl:118: called as libIE(myArg: int(64)) check-gc-reuse-opers.chpl:24: In function 'libAS': check-gc-reuse-opers.chpl:24: warning: More1.= - check-gc-reuse-opers.chpl:118: called as libAS(myArg: int(64)) + check-gc-reuse-opers.chpl:119: called as libAS(myArg: int(64)) check-gc-reuse-opers.chpl:25: In function 'libLT': check-gc-reuse-opers.chpl:25: warning: More1.< - check-gc-reuse-opers.chpl:119: called as libLT(myArg: int(64)) + check-gc-reuse-opers.chpl:120: called as libLT(myArg: int(64)) check-gc-reuse-opers.chpl:26: In function 'libCF': check-gc-reuse-opers.chpl:26: warning: More1._castF - check-gc-reuse-opers.chpl:120: called as libCF(myArg: int(64)) + check-gc-reuse-opers.chpl:121: called as libCF(myArg: int(64)) check-gc-reuse-opers.chpl:27: In function 'libCT': check-gc-reuse-opers.chpl:27: warning: More1._castT - check-gc-reuse-opers.chpl:121: called as libCT(myArg: int(64)) -check-gc-reuse-opers.chpl:112: In function ':': -check-gc-reuse-opers.chpl:113: warning: More1.init + check-gc-reuse-opers.chpl:122: called as libCT(myArg: int(64)) +check-gc-reuse-opers.chpl:113: In function ':': +check-gc-reuse-opers.chpl:114: warning: More1.init check-gc-reuse-opers.chpl:27: called as :(rhs: int(64), type t = MyRecord) from function 'libCT' - check-gc-reuse-opers.chpl:121: called as libCT(myArg: int(64)) -check-gc-reuse-opers.chpl:123: In function 'm1gen': -check-gc-reuse-opers.chpl:124: warning: More1.m1gen - check-gc-reuse-opers.chpl:85: called as m1gen(param p = 0) -check-gc-reuse-opers.chpl:137: In function 'm2con': -check-gc-reuse-opers.chpl:138: warning: More2.m2con -check-gc-reuse-opers.chpl:141: In function 'm2gen': -check-gc-reuse-opers.chpl:142: warning: More2.m2gen - check-gc-reuse-opers.chpl:90: called as m2gen(param p = 0) -check-gc-reuse-opers.chpl:180: In function 'combo2a': -check-gc-reuse-opers.chpl:181: warning: Combo2.combo2a - check-gc-reuse-opers.chpl:164: called as combo2a(param p = 0) + check-gc-reuse-opers.chpl:122: called as libCT(myArg: int(64)) +check-gc-reuse-opers.chpl:124: In function 'm1gen': +check-gc-reuse-opers.chpl:125: warning: More1.m1gen + check-gc-reuse-opers.chpl:86: called as m1gen(param p = 0) +check-gc-reuse-opers.chpl:138: In function 'm2con': +check-gc-reuse-opers.chpl:139: warning: More2.m2con +check-gc-reuse-opers.chpl:142: In function 'm2gen': +check-gc-reuse-opers.chpl:143: warning: More2.m2gen + check-gc-reuse-opers.chpl:91: called as m2gen(param p = 0) +check-gc-reuse-opers.chpl:181: In function 'combo2a': +check-gc-reuse-opers.chpl:182: warning: Combo2.combo2a + check-gc-reuse-opers.chpl:165: called as combo2a(param p = 0) check-gc-reuse-opers.chpl:23: In function 'libIE': check-gc-reuse-opers.chpl:23: warning: Combo1.init= - check-gc-reuse-opers.chpl:183: called as libIE(myArg: int(64)) from function 'combo2a' - check-gc-reuse-opers.chpl:164: called as combo2a(param p = 0) + check-gc-reuse-opers.chpl:184: called as libIE(myArg: int(64)) from function 'combo2a' + check-gc-reuse-opers.chpl:165: called as combo2a(param p = 0) check-gc-reuse-opers.chpl:24: In function 'libAS': check-gc-reuse-opers.chpl:24: warning: Combo1.= - check-gc-reuse-opers.chpl:184: called as libAS(myArg: int(64)) from function 'combo2a' - check-gc-reuse-opers.chpl:164: called as combo2a(param p = 0) + check-gc-reuse-opers.chpl:185: called as libAS(myArg: int(64)) from function 'combo2a' + check-gc-reuse-opers.chpl:165: called as combo2a(param p = 0) check-gc-reuse-opers.chpl:25: In function 'libLT': check-gc-reuse-opers.chpl:25: warning: Combo1.< - check-gc-reuse-opers.chpl:185: called as libLT(myArg: int(64)) from function 'combo2a' - check-gc-reuse-opers.chpl:164: called as combo2a(param p = 0) + check-gc-reuse-opers.chpl:186: called as libLT(myArg: int(64)) from function 'combo2a' + check-gc-reuse-opers.chpl:165: called as combo2a(param p = 0) check-gc-reuse-opers.chpl:26: In function 'libCF': check-gc-reuse-opers.chpl:26: warning: Combo1._castF - check-gc-reuse-opers.chpl:186: called as libCF(myArg: int(64)) from function 'combo2a' - check-gc-reuse-opers.chpl:164: called as combo2a(param p = 0) + check-gc-reuse-opers.chpl:187: called as libCF(myArg: int(64)) from function 'combo2a' + check-gc-reuse-opers.chpl:165: called as combo2a(param p = 0) check-gc-reuse-opers.chpl:27: In function 'libCT': check-gc-reuse-opers.chpl:27: warning: Combo1._castT - check-gc-reuse-opers.chpl:187: called as libCT(myArg: int(64)) from function 'combo2a' - check-gc-reuse-opers.chpl:164: called as combo2a(param p = 0) -check-gc-reuse-opers.chpl:160: In function ':': -check-gc-reuse-opers.chpl:161: warning: Combo1.init + check-gc-reuse-opers.chpl:188: called as libCT(myArg: int(64)) from function 'combo2a' + check-gc-reuse-opers.chpl:165: called as combo2a(param p = 0) +check-gc-reuse-opers.chpl:161: In function ':': +check-gc-reuse-opers.chpl:162: warning: Combo1.init check-gc-reuse-opers.chpl:27: called as :(rhs: int(64), type t = MyRecord) from function 'libCT' - check-gc-reuse-opers.chpl:187: called as libCT(myArg: int(64)) from function 'combo2a' - check-gc-reuse-opers.chpl:164: called as combo2a(param p = 0) -check-gc-reuse-opers.chpl:166: In function 'combo1b': -check-gc-reuse-opers.chpl:167: warning: Combo1.combo1b - check-gc-reuse-opers.chpl:191: called as combo1b(param p = 0) + check-gc-reuse-opers.chpl:188: called as libCT(myArg: int(64)) from function 'combo2a' + check-gc-reuse-opers.chpl:165: called as combo2a(param p = 0) +check-gc-reuse-opers.chpl:167: In function 'combo1b': +check-gc-reuse-opers.chpl:168: warning: Combo1.combo1b + check-gc-reuse-opers.chpl:192: called as combo1b(param p = 0) User.u1 User.init @@ -120,12 +115,12 @@ User.init User.u3 User.init -u3.init= +User.init= u3.= u3.< u3._castF u3._castT -u3.init +User.init More1.m1con User.init From 6f88b4abd7686d6aefd651887130e1844018fdff Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 16:31:35 -0400 Subject: [PATCH 63/96] Use non-method operator in inlineKeyword To avoid ambiguity error --- Signed-off-by: Michael Ferguson --- test/functions/hilde/inlineKeyword.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functions/hilde/inlineKeyword.chpl b/test/functions/hilde/inlineKeyword.chpl index e69a5686b1bd..49bbf4ce219e 100644 --- a/test/functions/hilde/inlineKeyword.chpl +++ b/test/functions/hilde/inlineKeyword.chpl @@ -1,5 +1,5 @@ // Test that inline works as a keyword. -inline operator real.+(a: real, b: real) return 10.0; +inline operator +(a: real, b: real) return 10.0; var y = 1.0; var x = y + 2.0; From d55bb2c820c7379e53bd6a17919dfd7702b53fc5 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 17:00:06 -0400 Subject: [PATCH 64/96] overload set checking uses isMoreVisible on methods otherwise we see a failure in functions/operatorOverloads/operatorMethods/allOps/ioOperator.chpl at least. --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index ec0a351545f5..6ba26370424b 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -1960,10 +1960,6 @@ isMoreVisibleInternal(BlockStmt* block, FnSymbol* fn1, FnSymbol* fn2, // static MoreVisibleResult isMoreVisible(Expr* expr, FnSymbol* fn1, FnSymbol* fn2) { - // Do not consider methods more visible in disambiguation - if (fn1->isMethod() || fn2->isMethod()) - return FOUND_NEITHER; - // // common-case check to see if functions have equal visibility // @@ -5644,8 +5640,14 @@ static int compareSpecificity(ResolutionCandidate* candidate1, prefer2 = DS.fn2MoreSpecific; } else { - // If the decision hasn't been made based on the argument mappings... - auto v = isMoreVisible(DC.scope, candidate1->fn, candidate2->fn); + MoreVisibleResult v = FOUND_NEITHER; + // If the decision hasn't been made based on the argument mappings, + // consider visibility... + // But, do not consider visibility for methods in disambiguation. + if (!(candidate1->fn->isMethod() || candidate2->fn->isMethod())) { + v = isMoreVisible(DC.scope, candidate1->fn, candidate2->fn); + } + if (v == FOUND_F1_FIRST) { EXPLAIN("\nQ: preferring more visible function\n"); prefer1 = true; From 62c74acb73536735af640e34474d69460d523094 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 17:05:53 -0400 Subject: [PATCH 65/96] Add != on chpl_taskID_t We already had == on chpl_taskID_t --- Signed-off-by: Michael Ferguson --- modules/internal/ChapelTaskID.chpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/internal/ChapelTaskID.chpl b/modules/internal/ChapelTaskID.chpl index 2111f9d5ba02..17a9beaeeb50 100644 --- a/modules/internal/ChapelTaskID.chpl +++ b/modules/internal/ChapelTaskID.chpl @@ -30,6 +30,9 @@ module ChapelTaskID { inline operator ==(a: chpl_taskID_t, b: chpl_taskID_t) return __primitive("==", a, b); + inline operator !=(a: chpl_taskID_t, b: chpl_taskID_t) + return __primitive("!=", a, b); + inline operator :(x: chpl_taskID_t, type t: int(64)) return __primitive("cast", t, x); From 41020fb4cdff21b6ace180ff862faaf7afa00278 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 17:06:09 -0400 Subject: [PATCH 66/96] Remove local chpl_taskID_t operators Now that they are defined in ChapelTaskID.chpl --- Signed-off-by: Michael Ferguson --- test/parallel/taskPar/sungeun/private.chpl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/parallel/taskPar/sungeun/private.chpl b/test/parallel/taskPar/sungeun/private.chpl index 232c3311e206..51bd4d5e8ccd 100644 --- a/test/parallel/taskPar/sungeun/private.chpl +++ b/test/parallel/taskPar/sungeun/private.chpl @@ -18,12 +18,6 @@ record taskPrivateData { } }; -inline operator chpl_taskID_t.=(ref a: chpl_taskID_t, b: chpl_taskID_t) { - __primitive("=", a, b); -} -inline operator chpl_taskID_t.!=(a: chpl_taskID_t, b: chpl_taskID_t) { - return __primitive("!=", a, b); -} class localePrivateData { type myStuff; // assumes maxTaskPar is the same across all locales From d919281c1cfe72f6c4d4e13f38e3502c3a58d9ea Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 17:11:07 -0400 Subject: [PATCH 67/96] Use non-operator method to avoid ambiguity --- Signed-off-by: Michael Ferguson --- test/types/coerce/diten/test_override_equals.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/coerce/diten/test_override_equals.chpl b/test/types/coerce/diten/test_override_equals.chpl index 39c43b06bf07..7e93e54ee68e 100644 --- a/test/types/coerce/diten/test_override_equals.chpl +++ b/test/types/coerce/diten/test_override_equals.chpl @@ -17,7 +17,7 @@ operator +(a: uint(64), b: int(64)) { // this test, though. Particularly since I'm not convinced // that it's a good idea for users to be overloading ==. // -operator int.==(a: int, b: int) { +operator ==(a: int, b: int) { writeln("Found my ==, but it's going to give != instead"); return a != b; } From 4d34506b50ea61d6bb915d808f3a1d1c39b21af6 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 17:12:25 -0400 Subject: [PATCH 68/96] Use non-method operator to avoid ambiguity --- Signed-off-by: Michael Ferguson --- test/types/scalar/bradc/bitNegateBoolUserDefined.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/scalar/bradc/bitNegateBoolUserDefined.chpl b/test/types/scalar/bradc/bitNegateBoolUserDefined.chpl index ab5e4fe5e7ef..da346d04f912 100644 --- a/test/types/scalar/bradc/bitNegateBoolUserDefined.chpl +++ b/test/types/scalar/bradc/bitNegateBoolUserDefined.chpl @@ -1,7 +1,7 @@ var t: bool = true; var f: bool = false; -operator bool.~(a: bool) return !a; +operator ~(a: bool) return !a; writeln("~true = ", ~t); writeln("~false = ", ~f); From cd1c1cb7c051fd5e56fb150145b182a41ac07772 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 17 Mar 2022 17:15:29 -0400 Subject: [PATCH 69/96] Update .good files for public use A not bringing in A --- Signed-off-by: Michael Ferguson --- test/visibility/import/useAndImport.good | 6 ++---- test/visibility/import/useAndImport2.good | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/test/visibility/import/useAndImport.good b/test/visibility/import/useAndImport.good index 613a51c729c2..f30111043976 100644 --- a/test/visibility/import/useAndImport.good +++ b/test/visibility/import/useAndImport.good @@ -1,4 +1,2 @@ -4 -4 -In A.foo() -In A.foo() +useAndImport.chpl:19: In function 'main': +useAndImport.chpl:21: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport2.good b/test/visibility/import/useAndImport2.good index 613a51c729c2..6c92805f96d4 100644 --- a/test/visibility/import/useAndImport2.good +++ b/test/visibility/import/useAndImport2.good @@ -1,4 +1,2 @@ -4 -4 -In A.foo() -In A.foo() +useAndImport2.chpl:19: In function 'main': +useAndImport2.chpl:21: error: 'A' undeclared (first use this function) From a8b987f463a95c773c92cd314722378e5571c46e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 18 Mar 2022 10:13:51 -0400 Subject: [PATCH 70/96] Add warning for 'public use M only;' --- Signed-off-by: Michael Ferguson --- compiler/AST/UseStmt.cpp | 13 +++++++++++++ compiler/include/UseStmt.h | 2 ++ compiler/passes/checkParsed.cpp | 19 +++++++++++++++++++ .../visibility/only/warn-public-use-only.chpl | 8 ++++++++ .../visibility/only/warn-public-use-only.good | 2 ++ 5 files changed, 44 insertions(+) create mode 100644 test/visibility/only/warn-public-use-only.chpl create mode 100644 test/visibility/only/warn-public-use-only.good diff --git a/compiler/AST/UseStmt.cpp b/compiler/AST/UseStmt.cpp index 5cef388a47ec..3b840d2ed445 100644 --- a/compiler/AST/UseStmt.cpp +++ b/compiler/AST/UseStmt.cpp @@ -150,6 +150,19 @@ bool UseStmt::hasOnlyList() const { return isPlainUse() == false && except == false; } +bool UseStmt::hasOnlyNothing() const { + if (hasOnlyList()) { + if (named.size() == 0) + return true; + + // also check for named containing just the empty string + if (named.size() == 1 && named[0][0] == '\0') + return true; + } + + return false; +} + bool UseStmt::hasExceptList() const { return isPlainUse() == false && except == true; } diff --git a/compiler/include/UseStmt.h b/compiler/include/UseStmt.h index fe42dc22c5b2..fcdf79340839 100644 --- a/compiler/include/UseStmt.h +++ b/compiler/include/UseStmt.h @@ -53,6 +53,8 @@ class UseStmt final : public VisibilityStmt { bool hasOnlyList() const; + bool hasOnlyNothing() const; + bool hasExceptList() const; void scopeResolve(ResolveScope* scope); diff --git a/compiler/passes/checkParsed.cpp b/compiler/passes/checkParsed.cpp index 6e9503f10523..5760b09807fa 100644 --- a/compiler/passes/checkParsed.cpp +++ b/compiler/passes/checkParsed.cpp @@ -47,6 +47,7 @@ static void setupForCheckExplicitDeinitCalls(); static void warnUnstableUnions(AggregateType* at); static void warnUnstableLeadingUnderscores(); static void checkOperator(FnSymbol* fn); +static void checkUseStmt(UseStmt* use); void checkParsed() { @@ -119,6 +120,10 @@ checkParsed() { checkExportedNames(); checkDefersAfterParsing(); + + forv_Vec(UseStmt, use, gUseStmts) { + checkUseStmt(use); + } } @@ -607,3 +612,17 @@ static void warnUnstableLeadingUnderscores() { } } } + +/* check for 'public use M only' and warn in that event since + it does nothing. (public use does not bring in the module named + unless it renames the module e.g. 'public use M as M only' */ +static void checkUseStmt(UseStmt* use) { + if (!use->isPrivate && !use->isARename() && use->hasOnlyNothing()) { + const char* name = "M"; + if (auto used = toUnresolvedSymExpr(use->src)) + name = used->unresolved; + USR_WARN(use, "'public use %s only;' has no effect", name); + USR_PRINT("try 'public import %s;' or 'public use %s as %s only;'", + name, name, name); + } +} diff --git a/test/visibility/only/warn-public-use-only.chpl b/test/visibility/only/warn-public-use-only.chpl new file mode 100644 index 000000000000..0dbb77816eec --- /dev/null +++ b/test/visibility/only/warn-public-use-only.chpl @@ -0,0 +1,8 @@ +module A { } +module B { + public use A only; +} +module D { + use B; + proc main() { } +} diff --git a/test/visibility/only/warn-public-use-only.good b/test/visibility/only/warn-public-use-only.good new file mode 100644 index 000000000000..a305bd04a34b --- /dev/null +++ b/test/visibility/only/warn-public-use-only.good @@ -0,0 +1,2 @@ +warn-public-use-only.chpl:3: warning: 'public use A only;' has no effect +note: try 'public import A;' or 'public use A as A only;' From d190dbfb3d60178147d2493687ac3419a26428b9 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 25 Mar 2022 16:24:43 -0400 Subject: [PATCH 71/96] Fix noAssignClass to error even if candidate not chosen --- Signed-off-by: Michael Ferguson --- compiler/resolution/resolveFunction.cpp | 49 +++++++++++++++------ test/classes/assignments/noAssignClass.good | 4 ++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index e4af318b9538..57a5b13a1fef 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -67,6 +67,8 @@ static ConversionsTable conversionsTable; static void resolveFormals(FnSymbol* fn); +static void checkForUnsupportedOverload(FnSymbol* fn); + static void markIteratorAndLoops(FnSymbol* fn, CallExpr* call); static void insertUnrefForArrayOrTupleReturn(FnSymbol* fn); @@ -95,15 +97,15 @@ void resolveSignatureAndFunction(FnSymbol* fn) { ************************************** | *************************************/ void resolveSignature(FnSymbol* fn) { - // Don't resolve formals for concrete functions - // more often than necessary. - static std::set done; + // Don't resolve formals for concrete functions + // more often than necessary. + static std::set done; - if (done.find(fn) == done.end()) { - done.insert(fn); + if (done.find(fn) == done.end()) { + done.insert(fn); - resolveFormals(fn); - } + resolveFormals(fn); + } } /************************************* | ************************************** @@ -188,6 +190,7 @@ static void resolveFormals(FnSymbol* fn) { storeDefaultValuesForPython(fn, formal); } } + checkForUnsupportedOverload(fn); } // When compiling for Python interoperability, default values for arguments @@ -605,6 +608,28 @@ static void markTypesWithDefaultInitEqOrAssign(FnSymbol* fn) { } } +static void checkForUnsupportedOverload(FnSymbol* fn) { + Type* toType = NULL; + + if (fn->name == astrSassign) { + int i = 1; + if (fn->getFormal(i)->typeInfo() == dtMethodToken) i++; + if (fn->getFormal(i)->hasFlag(FLAG_ARG_THIS)) i++; + toType = fn->getFormal(i)->getValType(); + + if (isClassLikeOrPtr(toType) || + isClassLikeOrManaged(toType) || + toType == dtNil) { + // don't allow '=' on these types to be defined + // outside of the standard/internal modules + if (fn->defPoint->getModule()->modTag == MOD_USER) { + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for class types"); + } + } + } +} + static void resolveAlsoConversions(FnSymbol* fn, CallExpr* forCall) { Type* toType = NULL; @@ -693,13 +718,9 @@ static void resolveAlsoConversions(FnSymbol* fn, CallExpr* forCall) { checkInitEq = false; checkCast = false; - // However, don't allow '=' on these types to be defined - // outside of the standard/internal modules - if (have.assign != NULL && - have.assign->defPoint->getModule()->modTag == MOD_USER) { - USR_FATAL_CONT(have.assign->defPoint, - "Can't overload assignments for class types"); - } + // Checked for '=' on classes in user modules in + // checkForUnsupportedOverload called from resolveSignature + // so don't need to check that here. } // Don't worry about checking for 'init=' for tuples or types diff --git a/test/classes/assignments/noAssignClass.good b/test/classes/assignments/noAssignClass.good index 47585a72482e..7c1a1023abbc 100644 --- a/test/classes/assignments/noAssignClass.good +++ b/test/classes/assignments/noAssignClass.good @@ -7,8 +7,10 @@ noAssignClass.chpl:65: error: Can't overload assignments for class types noAssignClass.chpl:69: error: Can't overload assignments for class types noAssignClass.chpl:73: error: Can't overload assignments for class types noAssignClass.chpl:77: error: Can't overload assignments for class types +noAssignClass.chpl:77: error: Can't overload assignments for class types noAssignClass.chpl:81: error: Can't overload assignments for class types noAssignClass.chpl:85: error: Can't overload assignments for class types +noAssignClass.chpl:85: error: Can't overload assignments for class types noAssignClass.chpl:89: error: Can't overload assignments for class types noAssignClass.chpl:93: error: Can't overload assignments for class types noAssignClass.chpl:141: error: Can't overload assignments for class types @@ -20,5 +22,7 @@ noAssignClass.chpl:161: error: Can't overload assignments for class types noAssignClass.chpl:165: error: Can't overload assignments for class types noAssignClass.chpl:169: error: Can't overload assignments for class types noAssignClass.chpl:173: error: Can't overload assignments for class types +noAssignClass.chpl:173: error: Can't overload assignments for class types noAssignClass.chpl:177: error: Can't overload assignments for class types noAssignClass.chpl:181: error: Can't overload assignments for class types +noAssignClass.chpl:181: error: Can't overload assignments for class types From d9c8469a9720766324122e8fabc985ab7bd7943b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 25 Mar 2022 16:51:17 -0400 Subject: [PATCH 72/96] Don't warn for public use M only X as Y --- Signed-off-by: Michael Ferguson --- compiler/AST/UseStmt.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/AST/UseStmt.cpp b/compiler/AST/UseStmt.cpp index 3b840d2ed445..d06ae464fed0 100644 --- a/compiler/AST/UseStmt.cpp +++ b/compiler/AST/UseStmt.cpp @@ -152,12 +152,12 @@ bool UseStmt::hasOnlyList() const { bool UseStmt::hasOnlyNothing() const { if (hasOnlyList()) { - if (named.size() == 0) - return true; - - // also check for named containing just the empty string - if (named.size() == 1 && named[0][0] == '\0') - return true; + if (renamed.size() == 0) { + // check for named being empty or containing the empty string + if (named.size() == 0 || + (named.size() == 1 && named[0][0] == '\0')) + return true; + } } return false; From d58b03ee23062bd07a2f7297fd5bd0b3117e7d93 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 25 Mar 2022 16:51:41 -0400 Subject: [PATCH 73/96] Update useOnlyNothing tests Mostly I changed 'public use M only;' to 'public use M as M only;' in order for the test to continue doing something interesting. A few of them I left more the way they were & now show errors. --- Signed-off-by: Michael Ferguson --- .../multipleUnqualified/useAndImport-useOnlyNothing1a.chpl | 2 +- .../multipleUnqualified/useAndImport-useOnlyNothing1a.good | 2 ++ .../multipleUnqualified/useAndImport-useOnlyNothing1b.chpl | 2 +- .../multipleUnqualified/useAndImport-useOnlyNothing1b.good | 2 ++ .../multipleUnqualified/useAndImport-useOnlyNothing2a.chpl | 2 +- .../multipleUnqualified/useAndImport-useOnlyNothing2b.chpl | 2 +- .../multipleUnqualified/useAndImport-useOnlyNothing2c.chpl | 2 +- .../multipleUnqualified/useAndImport-useOnlyNothing2d.chpl | 2 +- .../enablesUnqualified/useAndImport-useOnlyNothing2a.chpl | 2 +- .../enablesUnqualified/useAndImport-useOnlyNothing2b.chpl | 2 +- .../enablesUnqualified/useAndImport-useOnlyNothing2c.chpl | 2 +- .../enablesUnqualified/useAndImport-useOnlyNothing2d.chpl | 2 +- .../visibility/import/public/useAndImport-useOnlyNothing1a.chpl | 2 +- .../visibility/import/public/useAndImport-useOnlyNothing1b.chpl | 2 +- .../visibility/import/public/useAndImport-useOnlyNothing2a.chpl | 2 +- .../visibility/import/public/useAndImport-useOnlyNothing2b.chpl | 2 +- .../visibility/import/public/useAndImport-useOnlyNothing2c.chpl | 2 +- .../visibility/import/public/useAndImport-useOnlyNothing2d.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing1a.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing1a.good | 2 ++ test/visibility/import/useAndImport-useOnlyNothing1b.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing1b.good | 2 ++ test/visibility/import/useAndImport-useOnlyNothing2a.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing2b.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing2c.chpl | 2 +- test/visibility/import/useAndImport-useOnlyNothing2d.chpl | 2 +- 26 files changed, 30 insertions(+), 22 deletions(-) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl index e8d85b97d8f0..366a3dba7a63 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A only; // intentionally does nothing } module C { diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good index 3377877a4d18..a9d7e0c7aefd 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1a.good @@ -1,2 +1,4 @@ +useAndImport-useOnlyNothing1a.chpl:11: warning: 'public use A only;' has no effect +note: try 'public import A;' or 'public use A as A only;' useAndImport-useOnlyNothing1a.chpl:21: In function 'main': useAndImport-useOnlyNothing1a.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl index f8b02f576b4d..c1e0134a35b4 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A only; // intentionally does nothing } module D { diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good index e2fb2fd62ad6..5778bbd4db5a 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing1b.good @@ -1,2 +1,4 @@ +useAndImport-useOnlyNothing1b.chpl:15: warning: 'public use A only;' has no effect +note: try 'public import A;' or 'public use A as A only;' useAndImport-useOnlyNothing1b.chpl:21: In function 'main': useAndImport-useOnlyNothing1b.chpl:24: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2a.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2a.chpl index 6cae0501a3d9..87dc38ef09bc 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2a.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2b.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2b.chpl index b72c106c0e34..ea3fcdd63181 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2b.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2b.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2c.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2c.chpl index 825615332128..d0481a124d2a 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2c.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2c.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2d.chpl b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2d.chpl index bc4ac2e6bd44..24e954106439 100644 --- a/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2d.chpl +++ b/test/visibility/import/enablesUnqualified/multipleUnqualified/useAndImport-useOnlyNothing2d.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2a.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2a.chpl index 2d3af1f71e6e..94d11cce5978 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2a.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2b.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2b.chpl index fcaf991147e9..506a4d726208 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2b.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2b.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2c.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2c.chpl index e00f5256e532..772f24a611b1 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2c.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2c.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2d.chpl b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2d.chpl index f0a3f04d7505..6f70e261b57b 100644 --- a/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2d.chpl +++ b/test/visibility/import/enablesUnqualified/useAndImport-useOnlyNothing2d.chpl @@ -13,7 +13,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/public/useAndImport-useOnlyNothing1a.chpl b/test/visibility/import/public/useAndImport-useOnlyNothing1a.chpl index 465c5c4ee21c..fcf9108798bf 100644 --- a/test/visibility/import/public/useAndImport-useOnlyNothing1a.chpl +++ b/test/visibility/import/public/useAndImport-useOnlyNothing1a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/public/useAndImport-useOnlyNothing1b.chpl b/test/visibility/import/public/useAndImport-useOnlyNothing1b.chpl index 60c9da23b887..91d9642863ff 100644 --- a/test/visibility/import/public/useAndImport-useOnlyNothing1b.chpl +++ b/test/visibility/import/public/useAndImport-useOnlyNothing1b.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/public/useAndImport-useOnlyNothing2a.chpl b/test/visibility/import/public/useAndImport-useOnlyNothing2a.chpl index 3087d462e9d0..ca037fdaa23a 100644 --- a/test/visibility/import/public/useAndImport-useOnlyNothing2a.chpl +++ b/test/visibility/import/public/useAndImport-useOnlyNothing2a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/public/useAndImport-useOnlyNothing2b.chpl b/test/visibility/import/public/useAndImport-useOnlyNothing2b.chpl index 42813dbd1e93..80278b0d0dd7 100644 --- a/test/visibility/import/public/useAndImport-useOnlyNothing2b.chpl +++ b/test/visibility/import/public/useAndImport-useOnlyNothing2b.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/public/useAndImport-useOnlyNothing2c.chpl b/test/visibility/import/public/useAndImport-useOnlyNothing2c.chpl index cb2aeaab0b1a..d23c964d4a87 100644 --- a/test/visibility/import/public/useAndImport-useOnlyNothing2c.chpl +++ b/test/visibility/import/public/useAndImport-useOnlyNothing2c.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/public/useAndImport-useOnlyNothing2d.chpl b/test/visibility/import/public/useAndImport-useOnlyNothing2d.chpl index 8e918ff14939..a9e32845f2f2 100644 --- a/test/visibility/import/public/useAndImport-useOnlyNothing2d.chpl +++ b/test/visibility/import/public/useAndImport-useOnlyNothing2d.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/useAndImport-useOnlyNothing1a.chpl b/test/visibility/import/useAndImport-useOnlyNothing1a.chpl index ada97107c983..0d32a631d56b 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1a.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing1a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A only; // intentionally does nothing } module C { diff --git a/test/visibility/import/useAndImport-useOnlyNothing1a.good b/test/visibility/import/useAndImport-useOnlyNothing1a.good index beb1cb6fd6a1..87c9659e769e 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1a.good +++ b/test/visibility/import/useAndImport-useOnlyNothing1a.good @@ -1,2 +1,4 @@ +useAndImport-useOnlyNothing1a.chpl:11: warning: 'public use A only;' has no effect +note: try 'public import A;' or 'public use A as A only;' useAndImport-useOnlyNothing1a.chpl:21: In function 'main': useAndImport-useOnlyNothing1a.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnlyNothing1b.chpl b/test/visibility/import/useAndImport-useOnlyNothing1b.chpl index 5ed5dc0c4a5c..57e751c64eea 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1b.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing1b.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A only; // intentionally does nothing } module D { diff --git a/test/visibility/import/useAndImport-useOnlyNothing1b.good b/test/visibility/import/useAndImport-useOnlyNothing1b.good index dd77af82539f..8b9c214f9ce8 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing1b.good +++ b/test/visibility/import/useAndImport-useOnlyNothing1b.good @@ -1,2 +1,4 @@ +useAndImport-useOnlyNothing1b.chpl:15: warning: 'public use A only;' has no effect +note: try 'public import A;' or 'public use A as A only;' useAndImport-useOnlyNothing1b.chpl:21: In function 'main': useAndImport-useOnlyNothing1b.chpl:23: error: 'A' undeclared (first use this function) diff --git a/test/visibility/import/useAndImport-useOnlyNothing2a.chpl b/test/visibility/import/useAndImport-useOnlyNothing2a.chpl index 4ab9214aa63c..1ac1bfc589fd 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing2a.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing2a.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/useAndImport-useOnlyNothing2b.chpl b/test/visibility/import/useAndImport-useOnlyNothing2b.chpl index 51e68ff4b3ad..52dbcaf9765c 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing2b.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing2b.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { diff --git a/test/visibility/import/useAndImport-useOnlyNothing2c.chpl b/test/visibility/import/useAndImport-useOnlyNothing2c.chpl index 74afb4120a57..4da84283c094 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing2c.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing2c.chpl @@ -8,7 +8,7 @@ module A { } } module B { - public use A only; + public use A as A only; } module C { diff --git a/test/visibility/import/useAndImport-useOnlyNothing2d.chpl b/test/visibility/import/useAndImport-useOnlyNothing2d.chpl index 6509bc35c546..a012b0e68ecd 100644 --- a/test/visibility/import/useAndImport-useOnlyNothing2d.chpl +++ b/test/visibility/import/useAndImport-useOnlyNothing2d.chpl @@ -12,7 +12,7 @@ module B { } module C { - public use A only; + public use A as A only; } module D { From a908f6d196d007665c94d5446be22f15f55ca866 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 28 Mar 2022 10:20:51 -0400 Subject: [PATCH 74/96] Improve a comment --- Signed-off-by: Michael Ferguson --- compiler/resolution/resolveFunction.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index 57a5b13a1fef..d5188a8ecd75 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -718,9 +718,9 @@ static void resolveAlsoConversions(FnSymbol* fn, CallExpr* forCall) { checkInitEq = false; checkCast = false; - // Checked for '=' on classes in user modules in - // checkForUnsupportedOverload called from resolveSignature - // so don't need to check that here. + // We already checked for '=' on classes in user modules in + // checkForUnsupportedOverload (called from resolveSignature). + // So, we don't need to check that here. } // Don't worry about checking for 'init=' for tuples or types From 013a388cef68a368840b4fcd7e349caea139b824 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 28 Mar 2022 13:09:17 -0400 Subject: [PATCH 75/96] Delete an out-of-date comment --- Signed-off-by: Michael Ferguson --- test/types/coerce/diten/test_override_equals.chpl | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/types/coerce/diten/test_override_equals.chpl b/test/types/coerce/diten/test_override_equals.chpl index 7e93e54ee68e..ae4276a74cd1 100644 --- a/test/types/coerce/diten/test_override_equals.chpl +++ b/test/types/coerce/diten/test_override_equals.chpl @@ -3,20 +3,6 @@ operator +(a: uint(64), b: int(64)) { return a + b:uint(64); } -// -// This no longer works because (a) ChapelBase.chpl also adds an -// overload of ==(int, int) and (b) standard modules do == on -// enums which find these two ==() calls ambiguous (neither is -// closer than the other, as in this test, and we don't supply -// ==() on enums for simplicity and to avoid the (arguably -// unnecessary) generic instantiation). -// -// If we wanted to support this overload by the user, I think -// the way to do it would be to provide ==() for matching enum -// types. That was a bigger change than I wanted to make for -// this test, though. Particularly since I'm not convinced -// that it's a good idea for users to be overloading ==. -// operator ==(a: int, b: int) { writeln("Found my ==, but it's going to give != instead"); return a != b; From f7b8898a0ea0b9c5d37f9fc7bd8b637aa256ad5e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 28 Mar 2022 13:40:35 -0400 Subject: [PATCH 76/96] Change breakList.good to "I got you" More to do with deciding about overload set checking and method visibility, but this behavior makes sense with what is implemented now. See https://github.com/chapel-lang/chapel/issues/19352#issuecomment-1079391291 --- Signed-off-by: Michael Ferguson --- test/classes/diten/breakList.good | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/classes/diten/breakList.good b/test/classes/diten/breakList.good index 2d18c58c117b..3caa3f510058 100644 --- a/test/classes/diten/breakList.good +++ b/test/classes/diten/breakList.good @@ -1,7 +1,2 @@ -breakList.chpl:23: In function 'bar': -breakList.chpl:26: error: multiple overload sets are applicable to this call -breakList.chpl:6: note: the best-matching candidate is here -breakList.chpl:3: note: ... defined in this module -$CHPL_HOME/modules/packages/LinkedLists.chpl:nnnn: note: even though the candidate here is also available -$CHPL_HOME/modules/packages/LinkedLists.chpl:nnnn: note: ... defined in this module -breakList.chpl:26: note: use --no-overload-sets-checks to disable overload sets errors +3.0 4.0 +breakList.chpl:7: error: halt reached - I Got you! From 0195a194bf1559d4ec7a8736f9df5a8816b0b90e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 28 Mar 2022 13:51:02 -0400 Subject: [PATCH 77/96] Improve Can't overload = error for ptr types --- Signed-off-by: Michael Ferguson --- compiler/resolution/resolveFunction.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index d5188a8ecd75..46e239ccf65d 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -623,8 +623,13 @@ static void checkForUnsupportedOverload(FnSymbol* fn) { // don't allow '=' on these types to be defined // outside of the standard/internal modules if (fn->defPoint->getModule()->modTag == MOD_USER) { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for class types"); + if (isClassLikeOrManaged(toType)) { + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for class types"); + } else { + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for pointer types"); + } } } } From 5b3b6a7083b6459dcafea65a0ace75fc6a9a575b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 28 Mar 2022 13:51:16 -0400 Subject: [PATCH 78/96] Included expected Can't override = error --- Signed-off-by: Michael Ferguson --- test/functions/sungeun/procEquals_c_string.good | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functions/sungeun/procEquals_c_string.good b/test/functions/sungeun/procEquals_c_string.good index e69de29bb2d1..a0ea24717c63 100644 --- a/test/functions/sungeun/procEquals_c_string.good +++ b/test/functions/sungeun/procEquals_c_string.good @@ -0,0 +1 @@ +procEquals_c_string.chpl:1: error: Can't overload assignments for pointer types From e648c661afb267ab350364a57e4c7615d8202963 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 28 Mar 2022 14:05:58 -0400 Subject: [PATCH 79/96] Move check for unsupported assignment overload For studies/amr/advection/amr/AMR_AdvectionCTU_driver (Otherwise the check happens before checking the where clause) --- Signed-off-by: Michael Ferguson --- compiler/include/resolveFunction.h | 2 ++ compiler/resolution/ResolutionCandidate.cpp | 3 +++ compiler/resolution/resolveFunction.cpp | 24 ++++++++++++--------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/compiler/include/resolveFunction.h b/compiler/include/resolveFunction.h index df8170f691cd..b60dfbbf085b 100644 --- a/compiler/include/resolveFunction.h +++ b/compiler/include/resolveFunction.h @@ -29,6 +29,8 @@ class VarSymbol; void resolveSignatureAndFunction(FnSymbol* fn); void resolveSignature(FnSymbol* fn); +void checkForUnsupportedOverload(FnSymbol* fn); + void resolveFunction(FnSymbol* fn, CallExpr* forCall = 0); bool isParallelIterator(FnSymbol* fn); diff --git a/compiler/resolution/ResolutionCandidate.cpp b/compiler/resolution/ResolutionCandidate.cpp index c80db6bff8ef..9b1afd034c4e 100644 --- a/compiler/resolution/ResolutionCandidate.cpp +++ b/compiler/resolution/ResolutionCandidate.cpp @@ -957,6 +957,9 @@ bool ResolutionCandidate::checkResolveFormalsWhereClauses(CallInfo& info, return false; } + // if it is a candidate, check for unsupported overload + checkForUnsupportedOverload(fn); + return true; } diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index 46e239ccf65d..fc8f66bc3ad9 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -67,8 +67,6 @@ static ConversionsTable conversionsTable; static void resolveFormals(FnSymbol* fn); -static void checkForUnsupportedOverload(FnSymbol* fn); - static void markIteratorAndLoops(FnSymbol* fn, CallExpr* call); static void insertUnrefForArrayOrTupleReturn(FnSymbol* fn); @@ -190,7 +188,6 @@ static void resolveFormals(FnSymbol* fn) { storeDefaultValuesForPython(fn, formal); } } - checkForUnsupportedOverload(fn); } // When compiling for Python interoperability, default values for arguments @@ -608,7 +605,10 @@ static void markTypesWithDefaultInitEqOrAssign(FnSymbol* fn) { } } -static void checkForUnsupportedOverload(FnSymbol* fn) { +void checkForUnsupportedOverload(FnSymbol* fn) { + // Just error for each function once + static std::set alreadyErrored; + Type* toType = NULL; if (fn->name == astrSassign) { @@ -623,12 +623,16 @@ static void checkForUnsupportedOverload(FnSymbol* fn) { // don't allow '=' on these types to be defined // outside of the standard/internal modules if (fn->defPoint->getModule()->modTag == MOD_USER) { - if (isClassLikeOrManaged(toType)) { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for class types"); - } else { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for pointer types"); + astlocT loc = fn->defPoint->astloc; + if (alreadyErrored.count(loc) == 0) { + if (isClassLikeOrManaged(toType)) { + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for class types"); + } else { + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for pointer types"); + } + alreadyErrored.insert(loc); } } } From 268cad797c62fb41f2a3cfd9132e849ed7bf15eb Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 15:15:27 -0400 Subject: [PATCH 80/96] Exit loop early when possible (based on review feedback) --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 6c5af60b3f98..017d76750cdb 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -1733,6 +1733,9 @@ static void eliminateLastResortSyms(std::vector& symbols) { anyLastResort = true; else anyNotLastResort = true; + + if (anyLastResort && anyNotLastResort) + break; } if (anyLastResort && anyNotLastResort) { From cdb34d6170e578b6605996296c6e778636a6e20f Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 15:39:34 -0400 Subject: [PATCH 81/96] Updated modules section --- Signed-off-by: Michael Ferguson --- doc/rst/language/spec/modules.rst | 102 +++++++++++++++--------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/doc/rst/language/spec/modules.rst b/doc/rst/language/spec/modules.rst index 8f6254f97976..6e72f2f1120a 100644 --- a/doc/rst/language/spec/modules.rst +++ b/doc/rst/language/spec/modules.rst @@ -327,38 +327,68 @@ access a module's symbols from outside of the module. For top-level modules, a ``use`` or ``import`` statement is required before referring to the module’s name or the symbols it contains within a given lexical scope. -The names that are made visible by a ``use`` or ``import`` statement are -inserted in to a new scope that immediately encloses the scope within which the -statement appears. This implies that the position of the ``use`` or ``import`` -statement within a scope has no effect on its behavior. If a scope includes -multiple ``use`` statements, multiple ``import`` statements, or a combination of -``import`` and ``use`` statements, then the newly-visible names are inserted -into a common enclosing scope. +The ``use`` and ``import`` statements themselves are processed in order, +so it is not possible to ``use`` a module that is only made available by +a later ``use``. + +The other mentiones of a name made visible by a ``use`` or ``import`` +statement can be at any position relative to the ``use`` or ``import``. + +Private ``use`` statements -- for example ``use M`` or ``private use M`` +- make the contents of the module available in a scope just outside of +the current one and the name of the module itself (``M`` in the xample) +available in a second scope just outside of that. In contrast, ``import`` +as well as ``public use`` do not use these implicit scopes. .. _Use_And_Import_Conflicts: Conflicts +++++++++ -The implicit scope added by ``use`` and ``import`` described in the previous -section follows the same rules about conflicting variables as other scopes (see +Variable names available through ``use`` or ``import`` +follow the same rules about conflicting variables as other scopes (see :ref:`Variable_Conflicts`). Thus an error will be signaled if multiple variables with the same name would be inserted into this enclosing scope and that name is accessed. Remember that this does not apply to functions unless they are also indistinguishable in other ways, see :ref:`Function_Overloading`. -Because symbols brought into scope by a ``use`` or ``import`` statement are +Because symbols brought into scope by a ``private use`` statement are placed at a scope enclosing where the statement appears, such symbols will be shadowed by other symbols with the same name defined in the scope with the statement. The symbols that are shadowed will only be accessible via -:ref:`Explicit_Naming`. +:ref:`Explicit_Naming`. For example: + + *Example (shadowing.chpl)*. + + .. code-block:: chapel + + module A { + var x: int; + } -Symbols defined by public ``use`` or ``import`` statements can impact the scope -they are inserted into in different ways (see :ref:`Public_Use` and -:ref:`Reexporting` for more information on the ``public`` keyword). Symbols -that are brought in by a ``public use`` for unqualified access are treated as -at successive distances relative to how many ``public use`` statements were -necessary to obtain them. For instance, + module MainMod { + use A; + var x = "hello"; + + proc main() { + writeln(x); + } + } + + This program will compile and print out ``hello`` because the use of + ``x`` refers to ``MainMod.x`` which shadows ``A.x`` because ``use A``, + which means the same as ``private use A``, introduces ``x`` in a scope + just outside of the scope of ``MainMod``. + + .. code-block:: printoutput + + hello + + +The ``public use`` and ``public import`` statements bring the names into +a single scope (the scope containing the ``use`` or ``import`` +statement). Once that occurs, the original source of the names is +irrelevant for the purpose of determining conflicts. For example: *Example (conflict1.chpl)*. @@ -384,30 +414,14 @@ necessary to obtain them. For instance, } } - This code demonstrates a module (MainMod) using two modules, B and C. Module - C defines a symbol named x, while module B publicly uses another module, A, - which also defines a symbol named x. The program as written will compile and - will print out the value of ``C.x``, which is ``false``, because A's x is - considered further away (it is made available to MainMod through `two` use - statements instead of just one). Thus, it will generate the following - output: - + This program does not compile because the use of ``x`` in ``main`` + could refer to ``A.x`` or to ``C.x``. + .. code-block:: printoutput conflict1.chpl:2: error: symbol x is multiply defined conflict1.chpl:10: note: also defined here - If, however, C had been publicly used by another module D and that was used - by MainMod instead, then the compiler cannot determine which of ``C.x`` and - ``A.x`` was intended for ``writeln(x);``. The program must use qualified - access to indicate which x to access. - -Symbols brought in directly by a ``public import`` are treated as though defined -*at* the scope with the ``public import`` for the purpose of determining -conflicts (see :ref:`Reexporting`). This means that if the ``public use`` in -module B of the previous example was instead replaced with a ``public import -A.x``, A's x would conflict with ``C.x`` when resolving the ``main`` -procedure's body. .. _Using_Modules: @@ -543,20 +557,10 @@ Use statements may be explicitly declared ``public`` or ``private``. By default, uses are ``private``. Making a use ``public`` causes its symbols to be transitively visible: if module A uses module B, and module B contains a public use of a module or enumerated type C, then -C’s public symbols will also be visible to A unless they are shadowed -by symbols of the same name in B. Conversely, if B's use of C is +C’s public symbols will also be visible to A. Conversely, if B's use of C is ``private`` then A will not be able to see C's symbols due to that ``use``. -This notion of transitivity extends to the case in which a scope -imports symbols from multiple modules or constants from multiple -enumeration types. For example if a module A uses modules B1, B2, B3 -and modules B1, B2, B3 publicly use modules C1, C2, C3 respectively, -then all of the public symbols in B1, B2, B3 have the potential to -shadow the public symbols of C1, C2, and C3. However an error is -signaled if C1, C2, C3 have conflicting public module-level -definitions of the same symbol. - Making a use ``public`` additionally causes its symbols to be visible as though they were defined in the scope with the use. This strategy is called `re-exporting`. More information about re-exporting can be found in the @@ -934,9 +938,7 @@ Re-exporting Making a use or import ``public`` causes the symbols brought in by that statement to be visible as though they were defined in the scope with the use or -import, a strategy which will be referred to as `re-exporting`. However, -symbols with the same name in the scope with the use or import will still take -precedence. +import, a strategy which will be referred to as `re-exporting`. *Example (use-reexport1.chpl)*. From 7469d613f4bc2fd5c5e306fbf4fb4e70f57e805b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 15:49:52 -0400 Subject: [PATCH 82/96] Remove comment since I can't think of a counterexample --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 017d76750cdb..209c2ea937a7 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -2034,9 +2034,6 @@ static void lookupUseImport(const char* name, if (mod->block == block) { // if the module is private, return, // since we can't access anything in it - // TODO: does this need to have a more involved check? - // could a private outer module use a private inner - // module and see it? if (publicOnly && mod->hasFlag(FLAG_PRIVATE)) { return; } From 6b12abad280170a8021d212da051fdc27319cd32 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:03:30 -0400 Subject: [PATCH 83/96] Update module primers * use ModToUse (since we normally capitalize module names) * update wording about shadowing to be specific to variables --- Signed-off-by: Michael Ferguson --- test/release/examples/primers/modules.chpl | 176 +++++++++++---------- 1 file changed, 89 insertions(+), 87 deletions(-) diff --git a/test/release/examples/primers/modules.chpl b/test/release/examples/primers/modules.chpl index fcddd408522e..ed7b37dcb2c0 100644 --- a/test/release/examples/primers/modules.chpl +++ b/test/release/examples/primers/modules.chpl @@ -25,12 +25,12 @@ the file (minus the .chpl suffix). The compiler can be directed to include modules in distinct files by naming them on the command line or by relying on the ``-M`` flag (see the :ref:`man page ` for exact details). - Here, we declare a module `modToUse`: + Here, we declare a module `ModToUse`: */ -module modToUse { +module ModToUse { /* In this case, ``foo`` is a public module-level variable that is defined - within the module ``modToUse`` */ + within the module ``ModToUse`` */ var foo = 12; /* As is ``bar``. */ @@ -41,18 +41,18 @@ module modToUse { nested scopes) can access it. Here, ``hiddenFoo`` is a private module-level variable, making it - only accessible to other code contained in ``modToUse`` + only accessible to other code contained in ``ModToUse`` */ private var hiddenFoo = false; - /* ``baz`` is a public function which is defined within ``modToUse`` */ + /* ``baz`` is a public function which is defined within ``ModToUse`` */ proc baz (x, y) { return x * (x + y); } /* ``hiddenBaz`` is a private function, which is also only accessible by - symbols contained in ``modToUse``. + symbols contained in ``ModToUse``. */ private proc hiddenBaz(a) { writeln(a); @@ -75,7 +75,7 @@ module modToUse { writeln("In Rec.method2()"); } -} // end of modToUse module +} // end of ModToUse module /* In the current implementation, ``private`` cannot be applied to type definitions; type aliases, and declarations of enums, records, and @@ -96,7 +96,7 @@ module ThirdModule { module Conflict { - /* This variable shares a name with a symbol in ``modToUse``. */ + /* This variable shares a name with a symbol in ``ModToUse``. */ var bar = 5; var other = 5.0 + 3i; @@ -106,7 +106,7 @@ module Conflict { module DifferentArguments { - /* This function shares a name with a function in ``modToUse``, but takes + /* This function shares a name with a function in ``ModToUse``, but takes different arguments */ proc baz(x) { return x - 2; @@ -114,7 +114,7 @@ module DifferentArguments { } // end of DifferentArguments module module RecMoreMethods { - private use modToUse; + private use ModToUse; /* ``method3`` is a tertiary method defined on ``Rec`` */ proc Rec.method3() { @@ -139,11 +139,11 @@ module MainModule { directly in an unqualified manner (without a module name prefix). In this case, ``bazBarFoo`` should store the result of calling - ``modToUse.baz`` on ``modToUse.bar`` and ``modToUse.foo``, which is + ``ModToUse.baz`` on ``ModToUse.bar`` and ``ModToUse.foo``, which is in this case ``28``. */ { - use modToUse; + use ModToUse; var bazBarFoo = baz(bar, foo); writeln(bazBarFoo); @@ -152,7 +152,7 @@ module MainModule { /* Since ``use`` statements only affect their containing scope, when we leave a scope like this, we lose access to the module's symbols. For instance, since the following line isn't within a scope that contains a - ``use`` of ``modToUse``, it would generate an error if uncommented. + ``use`` of ``ModToUse``, it would generate an error if uncommented. This is because ``foo`` is not visible within our lexical scope or via any ``use`` statements in that scope. */ @@ -167,29 +167,29 @@ module MainModule { This demonstrates an ``import`` that enables access with the module prefix. In this example, ``bazBarFoo`` should store the result of - calling ``modToUse.baz`` on ``modToUse.bar`` and ``modToUse.foo``, which + calling ``ModToUse.baz`` on ``ModToUse.bar`` and ``ModToUse.foo``, which is in this case ``28``. */ { - import modToUse; + import ModToUse; - var bazBarFoo = modToUse.baz(modToUse.bar, modToUse.foo); + var bazBarFoo = ModToUse.baz(ModToUse.bar, ModToUse.foo); writeln(bazBarFoo); } /* This case demonstrates an ``import`` that enables access without the - module prefix to a single symbol within ``modToUse``. + module prefix to a single symbol within ``ModToUse``. */ { - import modToUse.bar; + import ModToUse.bar; writeln(bar); } /* ``import`` statements also only affect their containing scope, so similarly the following line would generate an error if uncommented, due - to being outside a scope with an ``import`` or ``use`` of ``modToUse``. + to being outside a scope with an ``import`` or ``use`` of ``ModToUse``. */ - // var twiceFoo = 2 * modToUse.foo; + // var twiceFoo = 2 * ModToUse.foo; /* ``use`` statements apply to the entire scope in which they are defined. @@ -200,14 +200,14 @@ module MainModule { in a scope from calling one declared later. Thus, as in an earlier example, the following declaration of - ``bazBarFoo`` will store the result of calling ``modToUse.baz`` - on ``modToUse.bar`` and ``modToUse.foo``, which is again + ``bazBarFoo`` will store the result of calling ``ModToUse.baz`` + on ``ModToUse.bar`` and ``ModToUse.foo``, which is again ``28``. */ { var bazBarFoo = baz(bar, foo); - use modToUse; + use ModToUse; writeln(bazBarFoo); } @@ -221,35 +221,35 @@ module MainModule { statement counterpart. */ { - var bazBarFoo = modToUse.baz(modToUse.bar, modToUse.foo); + var bazBarFoo = ModToUse.baz(ModToUse.bar, ModToUse.foo); - import modToUse; + import ModToUse; writeln(bazBarFoo); } /* Modules that are being used can be given a different name than the ones - they were declared with. In this example, ``modToUse.bar`` can be + they were declared with. In this example, ``ModToUse.bar`` can be accessed using the new name, ``other``, as the module prefix. The old name is not visible in that scope, though, so writing just - ``modToUse.bar`` will not work. However, unprefixed access to the + ``ModToUse.bar`` will not work. However, unprefixed access to the module's symbols remains unchanged. */ { - use modToUse as other; + use ModToUse as other; writeln(other.bar); - // writeln(modToUse.bar); // would be an error, modToUse not visible + // writeln(ModToUse.bar); // would be an error, ModToUse not visible writeln(bar); } /* The same is also true of modules that are imported. */ { - import modToUse as other; + import ModToUse as other; writeln(other.bar); - // writeln(modToUse.bar); // would be an error, modToUse not visible + // writeln(ModToUse.bar); // would be an error, ModToUse not visible } /* With this syntax, a ``use`` statement can enable just unqualified access @@ -257,48 +257,50 @@ module MainModule { statements doesn't enable qualified access. */ { - use modToUse as _; + use ModToUse as _; writeln(bar); - // writeln(modToUse.bar); // would be an error, modToUse not visible + // writeln(ModToUse.bar); // would be an error, ModToUse not visible // writeln(_.bar); // also an error, _ is not an identifier otherwise } - /* The symbols provided by a private ``use`` statement are only considered + /* Variables provided by a private ``use`` statement are only considered when the name in question cannot be resolved directly within the local scope. Thus, because another ``bar`` is defined within this scope, the access to ``bar`` within the ``writeln`` will refer to the local - variable ``bar`` rather than to ``modToUse.bar``. + variable ``bar`` rather than to ``ModToUse.bar``. */ { var bar = 4.0; - use modToUse; + use ModToUse; writeln(bar); // Will output the value of the bar defined in this scope (which is - // '4.0'), rather than the value of modToUse.bar (which is '2') + // '4.0'), rather than the value of ModToUse.bar (which is '2') } - /* In contrast, defining a symbol with the same name as something - imported leads to a multiple definition error. */ + /* In contrast, defining a variable with the same name as something + imported or brought in by ``public use`` leads to a multiple definition + error. */ /* If a symbol cannot be resolved directly within the local scope, then - the symbols provided by a ``use`` statement are considered before the + the symbols provided by a ``private use`` / ```use`` statements are + considered before the symbols defined outside of the scope where the ``use`` statement applies. Thus, because the other ``bar`` was defined outside of these curly braces, the compiler will find the ``bar`` from - ``modToUse`` when resolving the access within the ``writeln``, - rather than the outer ``bar``. The ``bar`` from ``modToUse`` is said + ``ModToUse`` when resolving the access within the ``writeln``, + rather than the outer ``bar``. The ``bar`` from ``ModToUse`` is said to be "shadowing" the definition at the outer scope. */ { var bar = false; { - use modToUse; + use ModToUse; writeln(bar); - // Will output the value of modToUse.bar (which is '2'), rather + // Will output the value of ModToUse.bar (which is '2'), rather // than the value of the bar defined outside of this scope (which // is 'false') } @@ -310,9 +312,9 @@ module MainModule { var bar = false; { - import modToUse.bar; + import ModToUse.bar; writeln(bar); - // Will output the value of modToUse.bar (which is '2'), rather + // Will output the value of ModToUse.bar (which is '2'), rather // than the value of the bar defined outside of this scope (which // is 'false') } @@ -320,40 +322,40 @@ module MainModule { /* Multiple modules may be named in a single ``use`` statement */ { - use modToUse, AnotherModule, ThirdModule; + use ModToUse, AnotherModule, ThirdModule; if (a || b < 0) { // Refers to AnotherModule.a (which is 'false') and ThirdModule.b (which // is '-13.0') - writeln(foo); // Refers to modToUse.foo + writeln(foo); // Refers to ModToUse.foo } else { - writeln(bar); // Refers to modToUse.bar - } // Will output modToUse.foo (which is '12') + writeln(bar); // Refers to ModToUse.bar + } // Will output ModToUse.foo (which is '12') } /* Multiple modules may also be named in a single ``import`` statement */ { - import modToUse, AnotherModule, ThirdModule; + import ModToUse, AnotherModule, ThirdModule; if (AnotherModule.a || ThirdModule.b < 0) { - writeln(modToUse.foo); + writeln(ModToUse.foo); } else { - writeln(modToUse.bar); - } // Will output modToUse.foo (which is '12') + writeln(ModToUse.bar); + } // Will output ModToUse.foo (which is '12') } /* And such ``import`` statements can mix and match between importing modules and the symbols within them. */ { - import modToUse.{foo, bar}, AnotherModule, ThirdModule.b; + import ModToUse.{foo, bar}, AnotherModule, ThirdModule.b; if (AnotherModule.a || b < 0) { // Refers to ThirdModule.b (which is '-13.0') - writeln(foo); // Refers to modToUse.foo + writeln(foo); // Refers to ModToUse.foo } else { - writeln(bar); // Refers to modToUse.bar - } // Will output modToUse.foo (which is '12') + writeln(bar); // Refers to ModToUse.bar + } // Will output ModToUse.foo (which is '12') } /* You can also ``import`` multiple modules in a single statement by naming @@ -364,31 +366,31 @@ module MainModule { /* Equivalently, a scope may contain multiple ``use`` statements */ { - use modToUse; + use ModToUse; use AnotherModule, ThirdModule; writeln(a && foo > 15); - // outputs false (because AnotherModule.a is 'false' and modToUse.foo is + // outputs false (because AnotherModule.a is 'false' and ModToUse.foo is // '12') } /* A scope may also contain multiple ``import`` statements */ { - import modToUse.foo; + import ModToUse.foo; import AnotherModule.a; writeln(a && foo > 15); - // outputs false (because AnotherModule.a is 'false' and modToUse.foo is + // outputs false (because AnotherModule.a is 'false' and ModToUse.foo is // '12') } /* It can even contain a mix of ``import`` and ``use`` statements */ { - use modToUse; + use ModToUse; import AnotherModule.a; writeln(a && foo > 15); - // outputs false (because AnotherModule.a is 'false' and modToUse.foo is + // outputs false (because AnotherModule.a is 'false' and ModToUse.foo is // '12') } @@ -402,13 +404,13 @@ module MainModule { scope, attempts to access a symbol by that name will result in a naming conflict. - The commented-out line below would fail because both ``modToUse`` and + The commented-out line below would fail because both ``ModToUse`` and ``Conflict`` define a symbol named ``bar``: */ { - use modToUse, Conflict; + use ModToUse, Conflict; - writeln(foo); // Outputs modToUse.foo ('12') + writeln(foo); // Outputs ModToUse.foo ('12') // writeln(bar); writeln(other); // Outputs Conflict.other ('5.0 + 3.0i') } @@ -431,10 +433,10 @@ module MainModule { */ { - use modToUse, DifferentArguments; + use ModToUse, DifferentArguments; writeln(baz(2, 3)); - // Accesses the function modToUse.baz using the two arguments. Should + // Accesses the function ModToUse.baz using the two arguments. Should // output 2 * (2 + 3) or '10' writeln(baz(3)); // Access the function DifferentArguments.baz using the single argument. @@ -462,11 +464,11 @@ module MainModule { { - use modToUse; + use ModToUse; use Conflict only other, another; - writeln(foo); // Outputs modToUse.foo ('12') - writeln(bar); // Outputs modToUse.bar ('2') + writeln(foo); // Outputs ModToUse.foo ('12') + writeln(bar); // Outputs ModToUse.bar ('2') writeln(other); // Outputs Conflict.other ('5.0 + 3.0i') } @@ -477,11 +479,11 @@ module MainModule { unqualified access. */ { - use modToUse; + use ModToUse; import Conflict.{other, another}; - writeln(foo); // Outputs modToUse.foo ('12') - writeln(bar); // Outputs modToUse.bar ('2') + writeln(foo); // Outputs ModToUse.foo ('12') + writeln(bar); // Outputs ModToUse.bar ('2') writeln(other); // Outputs Conflict.other ('5.0 + 3.0i') } @@ -491,9 +493,9 @@ module MainModule { */ { use Conflict; - use modToUse except bar; + use ModToUse except bar; - writeln(foo); // Outputs modToUse.foo ('12') + writeln(foo); // Outputs ModToUse.foo ('12') writeln(bar); // Outputs Conflict.bar ('5') writeln(other); // Outputs Conflict.other ('5.0 + 3.0i') } @@ -508,9 +510,9 @@ module MainModule { does not cause any conflicts with other included symbols. */ { - use modToUse; + use ModToUse; use Conflict only bar as boop; - writeln(bar); // Outputs modToUse.bar ('2') + writeln(bar); // Outputs ModToUse.bar ('2') writeln(boop); // Outputs Conflict.bar ('5') } @@ -518,9 +520,9 @@ module MainModule { braces. */ { - use modToUse; + use ModToUse; import Conflict.{bar as boop}; - writeln(bar); // Outputs modToUse.bar ('2') + writeln(bar); // Outputs ModToUse.bar ('2') writeln(boop); // Outputs Conflict.bar ('5') } @@ -530,9 +532,9 @@ module MainModule { always fully qualify accesses to their modules' symbols. */ { - use modToUse only; + use ModToUse only; use Conflict only; - writeln(modToUse.bar); // Outputs modToUse.bar ('2') + writeln(ModToUse.bar); // Outputs ModToUse.bar ('2') writeln(Conflict.bar); // Outputs Conflict.bar ('5') // writeln(bar); // this won't resolve since bar isn't available } @@ -540,9 +542,9 @@ module MainModule { /* Again, this is similar to an ``import`` of just the module itself. */ { - import modToUse; + import ModToUse; import Conflict; - writeln(modToUse.bar); // Outputs modToUse.bar ('2') + writeln(ModToUse.bar); // Outputs ModToUse.bar ('2') writeln(Conflict.bar); // Outputs Conflict.bar ('5') // writeln(bar); // this won't resolve since bar isn't available } @@ -557,8 +559,8 @@ module MainModule { one of the symbols listed in an ``import`` statement. */ { - use modToUse only; - var rec = new modToUse.Rec(4); // Only accessible via the module prefix + use ModToUse only; + var rec = new ModToUse.Rec(4); // Only accessible via the module prefix writeln(rec.field); // Accessible because we have an instance rec.method1(); // Ditto to the field case rec.method2(); From 3d5a20a610a4631e736e7a7db1beedcb184db6cb Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:10:36 -0400 Subject: [PATCH 84/96] Revert "Move check for unsupported assignment overload" This reverts commit 2c7ffce014efb693fd63862c036cc08a768af2ac. --- Signed-off-by: Michael Ferguson --- compiler/include/resolveFunction.h | 2 -- compiler/resolution/ResolutionCandidate.cpp | 3 --- compiler/resolution/resolveFunction.cpp | 24 +++++++++------------ 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/compiler/include/resolveFunction.h b/compiler/include/resolveFunction.h index b60dfbbf085b..df8170f691cd 100644 --- a/compiler/include/resolveFunction.h +++ b/compiler/include/resolveFunction.h @@ -29,8 +29,6 @@ class VarSymbol; void resolveSignatureAndFunction(FnSymbol* fn); void resolveSignature(FnSymbol* fn); -void checkForUnsupportedOverload(FnSymbol* fn); - void resolveFunction(FnSymbol* fn, CallExpr* forCall = 0); bool isParallelIterator(FnSymbol* fn); diff --git a/compiler/resolution/ResolutionCandidate.cpp b/compiler/resolution/ResolutionCandidate.cpp index 9b1afd034c4e..c80db6bff8ef 100644 --- a/compiler/resolution/ResolutionCandidate.cpp +++ b/compiler/resolution/ResolutionCandidate.cpp @@ -957,9 +957,6 @@ bool ResolutionCandidate::checkResolveFormalsWhereClauses(CallInfo& info, return false; } - // if it is a candidate, check for unsupported overload - checkForUnsupportedOverload(fn); - return true; } diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index fc8f66bc3ad9..46e239ccf65d 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -67,6 +67,8 @@ static ConversionsTable conversionsTable; static void resolveFormals(FnSymbol* fn); +static void checkForUnsupportedOverload(FnSymbol* fn); + static void markIteratorAndLoops(FnSymbol* fn, CallExpr* call); static void insertUnrefForArrayOrTupleReturn(FnSymbol* fn); @@ -188,6 +190,7 @@ static void resolveFormals(FnSymbol* fn) { storeDefaultValuesForPython(fn, formal); } } + checkForUnsupportedOverload(fn); } // When compiling for Python interoperability, default values for arguments @@ -605,10 +608,7 @@ static void markTypesWithDefaultInitEqOrAssign(FnSymbol* fn) { } } -void checkForUnsupportedOverload(FnSymbol* fn) { - // Just error for each function once - static std::set alreadyErrored; - +static void checkForUnsupportedOverload(FnSymbol* fn) { Type* toType = NULL; if (fn->name == astrSassign) { @@ -623,16 +623,12 @@ void checkForUnsupportedOverload(FnSymbol* fn) { // don't allow '=' on these types to be defined // outside of the standard/internal modules if (fn->defPoint->getModule()->modTag == MOD_USER) { - astlocT loc = fn->defPoint->astloc; - if (alreadyErrored.count(loc) == 0) { - if (isClassLikeOrManaged(toType)) { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for class types"); - } else { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for pointer types"); - } - alreadyErrored.insert(loc); + if (isClassLikeOrManaged(toType)) { + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for class types"); + } else { + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for pointer types"); } } } From 184e7f063774ee38c59fe95fc162244c60f5d80c Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:10:39 -0400 Subject: [PATCH 85/96] Revert "Included expected Can't override = error" This reverts commit a9c29cbd8a05ba5e78aef52520bd3bf9452ab709. --- Signed-off-by: Michael Ferguson --- test/functions/sungeun/procEquals_c_string.good | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functions/sungeun/procEquals_c_string.good b/test/functions/sungeun/procEquals_c_string.good index a0ea24717c63..e69de29bb2d1 100644 --- a/test/functions/sungeun/procEquals_c_string.good +++ b/test/functions/sungeun/procEquals_c_string.good @@ -1 +0,0 @@ -procEquals_c_string.chpl:1: error: Can't overload assignments for pointer types From d4c63dc8b4d999087a574a19c7b752f3c6e97fb8 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:10:42 -0400 Subject: [PATCH 86/96] Revert "Improve Can't overload = error for ptr types" This reverts commit 5683365d1f89f954a6ef699cd75a5e8a8fa17e05. --- Signed-off-by: Michael Ferguson --- compiler/resolution/resolveFunction.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index 46e239ccf65d..d5188a8ecd75 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -623,13 +623,8 @@ static void checkForUnsupportedOverload(FnSymbol* fn) { // don't allow '=' on these types to be defined // outside of the standard/internal modules if (fn->defPoint->getModule()->modTag == MOD_USER) { - if (isClassLikeOrManaged(toType)) { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for class types"); - } else { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for pointer types"); - } + USR_FATAL_CONT(fn->defPoint, + "Can't overload assignments for class types"); } } } From ffc698885819d4ff7830b0d7374d2d551f662762 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:15:46 -0400 Subject: [PATCH 87/96] Allow error for overloading assignment for c_string --- Signed-off-by: Michael Ferguson --- test/functions/sungeun/procEquals_c_string.good | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functions/sungeun/procEquals_c_string.good b/test/functions/sungeun/procEquals_c_string.good index e69de29bb2d1..3f5380aa5516 100644 --- a/test/functions/sungeun/procEquals_c_string.good +++ b/test/functions/sungeun/procEquals_c_string.good @@ -0,0 +1 @@ +procEquals_c_string.chpl:1: error: Can't overload assignments for class types From 2b26e8580a9c88fc9c9a38a5744a56436f61ccd4 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:17:29 -0400 Subject: [PATCH 88/96] Accept change in output for foo2 test for now Leaving improving it for future work --- Signed-off-by: Michael Ferguson --- test/modules/bradc/userInsteadOfStandard/foo2.good | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/modules/bradc/userInsteadOfStandard/foo2.good b/test/modules/bradc/userInsteadOfStandard/foo2.good index 87c14b275c88..9383fce53e76 100644 --- a/test/modules/bradc/userInsteadOfStandard/foo2.good +++ b/test/modules/bradc/userInsteadOfStandard/foo2.good @@ -1,3 +1,3 @@ warning: Ambiguous module source file -- using ./Math.chpl over $CHPL_HOME/modules/standard/Math.chpl -In my math! -In my foo2 +foo2.chpl:3: error: unresolved call 'testmath()' +foo2.chpl:3: note: because no functions named testmath found in scope From c656bb09054f0e60227982b536be8e32c567b7db Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:37:35 -0400 Subject: [PATCH 89/96] Improve function argument shadowing error To avoid an error for modules/diten/testIfModuleShadowsLocal --- Signed-off-by: Michael Ferguson --- compiler/passes/scopeResolve.cpp | 21 +++++++++++-------- .../diten/testIfModuleShadowsLocal.good | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/compiler/passes/scopeResolve.cpp b/compiler/passes/scopeResolve.cpp index 209c2ea937a7..466df19531c5 100644 --- a/compiler/passes/scopeResolve.cpp +++ b/compiler/passes/scopeResolve.cpp @@ -2192,15 +2192,18 @@ static void lookupUseImport(const char* name, // size() == 0, so we only need to do this check here because the // module case would hide it otherwise if (FnSymbol* fn = toFnSymbol(getScope(block))) { - // The next scope up from the block statement is a function - // symbol. That means that we need to check the arguments - if (Symbol* sym = inSymbolTable(name, fn)) { - // We found it in the arguments. This should cause a conflict, - // because it is probably an error that the user had the same - // name as a module level variable. - USR_WARN(sym, - "Module level symbol is hiding function argument '%s'", - name); + // if there is no variable with the same name in the block + if (nullptr == inSymbolTable(name, block)) { + // The next scope up from the block statement is a function + // symbol. That means that we need to check the arguments + if (Symbol* sym = inSymbolTable(name, fn)) { + // We found it in the arguments. This should cause a conflict, + // because it is probably an error that the user had the same + // name as a module level variable. + USR_WARN(sym, + "Module level symbol is hiding function argument '%s'", + name); + } } } } diff --git a/test/modules/diten/testIfModuleShadowsLocal.good b/test/modules/diten/testIfModuleShadowsLocal.good index 6bc2a4cc6a9c..ca67c99eda7b 100644 --- a/test/modules/diten/testIfModuleShadowsLocal.good +++ b/test/modules/diten/testIfModuleShadowsLocal.good @@ -1,2 +1 @@ -testIfModuleShadowsLocal.chpl:9: warning: Module level symbol is hiding function argument 'a' 1.0 + 2.0i From 80e8296b3cbf58d557c82fb123bd8c7205ae0de2 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:42:06 -0400 Subject: [PATCH 90/96] Include another example in modules primer --- Signed-off-by: Michael Ferguson --- test/release/examples/primers/modules.chpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/release/examples/primers/modules.chpl b/test/release/examples/primers/modules.chpl index ed7b37dcb2c0..eb8ded0f0ce7 100644 --- a/test/release/examples/primers/modules.chpl +++ b/test/release/examples/primers/modules.chpl @@ -283,6 +283,12 @@ module MainModule { /* In contrast, defining a variable with the same name as something imported or brought in by ``public use`` leads to a multiple definition error. */ + { + import ModToUse.bar; + var bar = 4.0; + + // writeln(bar); // multiple definition error + } /* If a symbol cannot be resolved directly within the local scope, then the symbols provided by a ``private use`` / ```use`` statements are From b30c0fdd005e3cf08c8ac007a3b4aaf63f9c60ed Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:55:42 -0400 Subject: [PATCH 91/96] Revert "Fix noAssignClass to error even if candidate not chosen" This reverts commit 5f36f1023167a0be083794bee1185683d600de20. --- Signed-off-by: Michael Ferguson --- compiler/resolution/resolveFunction.cpp | 49 ++++++--------------- test/classes/assignments/noAssignClass.good | 4 -- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index d5188a8ecd75..e4af318b9538 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -67,8 +67,6 @@ static ConversionsTable conversionsTable; static void resolveFormals(FnSymbol* fn); -static void checkForUnsupportedOverload(FnSymbol* fn); - static void markIteratorAndLoops(FnSymbol* fn, CallExpr* call); static void insertUnrefForArrayOrTupleReturn(FnSymbol* fn); @@ -97,15 +95,15 @@ void resolveSignatureAndFunction(FnSymbol* fn) { ************************************** | *************************************/ void resolveSignature(FnSymbol* fn) { - // Don't resolve formals for concrete functions - // more often than necessary. - static std::set done; + // Don't resolve formals for concrete functions + // more often than necessary. + static std::set done; - if (done.find(fn) == done.end()) { - done.insert(fn); + if (done.find(fn) == done.end()) { + done.insert(fn); - resolveFormals(fn); - } + resolveFormals(fn); + } } /************************************* | ************************************** @@ -190,7 +188,6 @@ static void resolveFormals(FnSymbol* fn) { storeDefaultValuesForPython(fn, formal); } } - checkForUnsupportedOverload(fn); } // When compiling for Python interoperability, default values for arguments @@ -608,28 +605,6 @@ static void markTypesWithDefaultInitEqOrAssign(FnSymbol* fn) { } } -static void checkForUnsupportedOverload(FnSymbol* fn) { - Type* toType = NULL; - - if (fn->name == astrSassign) { - int i = 1; - if (fn->getFormal(i)->typeInfo() == dtMethodToken) i++; - if (fn->getFormal(i)->hasFlag(FLAG_ARG_THIS)) i++; - toType = fn->getFormal(i)->getValType(); - - if (isClassLikeOrPtr(toType) || - isClassLikeOrManaged(toType) || - toType == dtNil) { - // don't allow '=' on these types to be defined - // outside of the standard/internal modules - if (fn->defPoint->getModule()->modTag == MOD_USER) { - USR_FATAL_CONT(fn->defPoint, - "Can't overload assignments for class types"); - } - } - } -} - static void resolveAlsoConversions(FnSymbol* fn, CallExpr* forCall) { Type* toType = NULL; @@ -718,9 +693,13 @@ static void resolveAlsoConversions(FnSymbol* fn, CallExpr* forCall) { checkInitEq = false; checkCast = false; - // We already checked for '=' on classes in user modules in - // checkForUnsupportedOverload (called from resolveSignature). - // So, we don't need to check that here. + // However, don't allow '=' on these types to be defined + // outside of the standard/internal modules + if (have.assign != NULL && + have.assign->defPoint->getModule()->modTag == MOD_USER) { + USR_FATAL_CONT(have.assign->defPoint, + "Can't overload assignments for class types"); + } } // Don't worry about checking for 'init=' for tuples or types diff --git a/test/classes/assignments/noAssignClass.good b/test/classes/assignments/noAssignClass.good index 7c1a1023abbc..47585a72482e 100644 --- a/test/classes/assignments/noAssignClass.good +++ b/test/classes/assignments/noAssignClass.good @@ -7,10 +7,8 @@ noAssignClass.chpl:65: error: Can't overload assignments for class types noAssignClass.chpl:69: error: Can't overload assignments for class types noAssignClass.chpl:73: error: Can't overload assignments for class types noAssignClass.chpl:77: error: Can't overload assignments for class types -noAssignClass.chpl:77: error: Can't overload assignments for class types noAssignClass.chpl:81: error: Can't overload assignments for class types noAssignClass.chpl:85: error: Can't overload assignments for class types -noAssignClass.chpl:85: error: Can't overload assignments for class types noAssignClass.chpl:89: error: Can't overload assignments for class types noAssignClass.chpl:93: error: Can't overload assignments for class types noAssignClass.chpl:141: error: Can't overload assignments for class types @@ -22,7 +20,5 @@ noAssignClass.chpl:161: error: Can't overload assignments for class types noAssignClass.chpl:165: error: Can't overload assignments for class types noAssignClass.chpl:169: error: Can't overload assignments for class types noAssignClass.chpl:173: error: Can't overload assignments for class types -noAssignClass.chpl:173: error: Can't overload assignments for class types noAssignClass.chpl:177: error: Can't overload assignments for class types noAssignClass.chpl:181: error: Can't overload assignments for class types -noAssignClass.chpl:181: error: Can't overload assignments for class types From c126dd1d85b43d6f707048064531a1a565ce3d16 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 6 May 2022 16:58:32 -0400 Subject: [PATCH 92/96] Accept fewer errors in noAssignClass --- Signed-off-by: Michael Ferguson --- test/classes/assignments/noAssignClass.good | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/classes/assignments/noAssignClass.good b/test/classes/assignments/noAssignClass.good index 47585a72482e..4d3a3ae19fc1 100644 --- a/test/classes/assignments/noAssignClass.good +++ b/test/classes/assignments/noAssignClass.good @@ -11,12 +11,10 @@ noAssignClass.chpl:81: error: Can't overload assignments for class types noAssignClass.chpl:85: error: Can't overload assignments for class types noAssignClass.chpl:89: error: Can't overload assignments for class types noAssignClass.chpl:93: error: Can't overload assignments for class types -noAssignClass.chpl:141: error: Can't overload assignments for class types noAssignClass.chpl:145: error: Can't overload assignments for class types noAssignClass.chpl:149: error: Can't overload assignments for class types noAssignClass.chpl:153: error: Can't overload assignments for class types noAssignClass.chpl:157: error: Can't overload assignments for class types -noAssignClass.chpl:161: error: Can't overload assignments for class types noAssignClass.chpl:165: error: Can't overload assignments for class types noAssignClass.chpl:169: error: Can't overload assignments for class types noAssignClass.chpl:173: error: Can't overload assignments for class types From 54cfad767a1d597efdd3328fe4ecb82cc38c112a Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 9 May 2022 14:44:00 -0400 Subject: [PATCH 93/96] Add param to enable this/local this, use in autoLocalAccess tests The previous approach relied on method shadowing which is no longer available. Now there are 2 params; one enables logging for distributed array accesses (which is usually what these tests want) and the other enables logging for all accesses (which a couple of these tests want). --- Signed-off-by: Michael Ferguson --- modules/internal/ChapelArray.chpl | 29 ++ .../differentButAlignedDoms.chpl | 12 - .../differentButAlignedDoms.compopts | 1 + .../differentButAlignedDoms.good | 248 +++++++++--------- .../autoLocalAccess/elemAsIndex.chpl | 12 - .../autoLocalAccess/elemAsIndex.compopts | 1 + .../autoLocalAccess/elemAsIndex.good | 36 +-- .../autoLocalAccess/flags-full.good | 88 +++---- .../autoLocalAccess/flags-none.good | 88 +++---- .../autoLocalAccess/flags-staticonly.good | 88 +++---- test/optimizations/autoLocalAccess/flags.chpl | 11 - .../autoLocalAccess/flags.compopts | 6 +- .../autoLocalAccess/localArrays-1D-COO.good | 18 ++ .../autoLocalAccess/localArrays-1D-DR.good | 18 ++ .../autoLocalAccess/localArrays-2D-COO.good | 20 ++ .../autoLocalAccess/localArrays-2D-DR.good | 27 ++ .../autoLocalAccess/localArrays-CSC.good | 20 ++ .../autoLocalAccess/localArrays-CSR.good | 20 ++ .../autoLocalAccess/localArrays-assoc.good | 18 ++ .../autoLocalAccess/localArrays.chpl | 63 +---- .../autoLocalAccess/localArrays.compopts | 7 + .../autoLocalAccess/localArrays.good | 76 ------ .../autoLocalAccess/localArrays.prediff | 10 + .../oneStaticFailOtherDynamicSuccess.chpl | 11 - .../oneStaticFailOtherDynamicSuccess.good | 34 +-- .../autoLocalAccess/preventMultiCall.chpl | 12 - .../autoLocalAccess/preventMultiCall.compopts | 1 + .../autoLocalAccess/preventMultiCall.good | 84 +++--- .../autoLocalAccess/preventMultiCallIter.chpl | 19 +- .../preventMultiCallIter.compopts | 1 + .../autoLocalAccess/preventMultiCallIter.good | 84 +++--- test/optimizations/autoLocalAccess/views.chpl | 25 -- .../autoLocalAccess/views.compopts | 1 + test/optimizations/autoLocalAccess/views.good | 88 +++---- .../autoLocalAccess/views.prediff | 11 + .../zipper/differentButAlignedDoms.chpl | 12 - .../zipper/differentButAlignedDoms.compopts | 1 + .../zipper/differentButAlignedDoms.good | 248 +++++++++--------- .../autoLocalAccess/zipper/elemAsIndex.chpl | 12 - .../zipper/elemAsIndex.compopts | 1 + .../autoLocalAccess/zipper/elemAsIndex.good | 36 +-- .../oneStaticFailOtherDynamicSuccess.chpl | 11 - .../oneStaticFailOtherDynamicSuccess.compopts | 1 + .../oneStaticFailOtherDynamicSuccess.good | 44 ++-- .../zipper/preventMultiCall.chpl | 12 - .../zipper/preventMultiCall.compopts | 1 + .../zipper/preventMultiCall.good | 84 +++--- .../zipper/preventMultiCallIter.chpl | 20 +- .../zipper/preventMultiCallIter.compopts | 1 + .../zipper/preventMultiCallIter.good | 84 +++--- .../autoLocalAccess/zipper/views.chpl | 25 -- .../autoLocalAccess/zipper/views.compopts | 1 + .../autoLocalAccess/zipper/views.good | 88 +++---- .../autoLocalAccess/zipper/views.prediff | 1 + 54 files changed, 937 insertions(+), 1034 deletions(-) create mode 100644 test/optimizations/autoLocalAccess/differentButAlignedDoms.compopts create mode 100644 test/optimizations/autoLocalAccess/elemAsIndex.compopts create mode 100644 test/optimizations/autoLocalAccess/localArrays-1D-COO.good create mode 100644 test/optimizations/autoLocalAccess/localArrays-1D-DR.good create mode 100644 test/optimizations/autoLocalAccess/localArrays-2D-COO.good create mode 100644 test/optimizations/autoLocalAccess/localArrays-2D-DR.good create mode 100644 test/optimizations/autoLocalAccess/localArrays-CSC.good create mode 100644 test/optimizations/autoLocalAccess/localArrays-CSR.good create mode 100644 test/optimizations/autoLocalAccess/localArrays-assoc.good create mode 100644 test/optimizations/autoLocalAccess/localArrays.compopts delete mode 100644 test/optimizations/autoLocalAccess/localArrays.good create mode 100755 test/optimizations/autoLocalAccess/localArrays.prediff create mode 100644 test/optimizations/autoLocalAccess/preventMultiCall.compopts create mode 100644 test/optimizations/autoLocalAccess/preventMultiCallIter.compopts create mode 100644 test/optimizations/autoLocalAccess/views.compopts create mode 100755 test/optimizations/autoLocalAccess/views.prediff create mode 100644 test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.compopts create mode 100644 test/optimizations/autoLocalAccess/zipper/elemAsIndex.compopts create mode 100644 test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.compopts create mode 100644 test/optimizations/autoLocalAccess/zipper/preventMultiCall.compopts create mode 100644 test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.compopts create mode 100644 test/optimizations/autoLocalAccess/zipper/views.compopts create mode 120000 test/optimizations/autoLocalAccess/zipper/views.prediff diff --git a/modules/internal/ChapelArray.chpl b/modules/internal/ChapelArray.chpl index 2008b2f28998..c8f0ed6debea 100644 --- a/modules/internal/ChapelArray.chpl +++ b/modules/internal/ChapelArray.chpl @@ -80,6 +80,11 @@ module ChapelArray { pragma "no doc" config param debugArrayAsVec = false; + pragma "no doc" + config param logDistArrEltAccess = false; + pragma "no doc" + config param logAllArrEltAccess = false; + proc _isPrivatized(value) param return !_local && ((_privatization && value!.dsiSupportsPrivatization()) || value!.dsiRequiresPrivatization()); @@ -1016,6 +1021,10 @@ module ChapelArray { if boundsChecking then checkAccess(i, value=value); + if logAllArrEltAccess || + (logDistArrEltAccess && !chpl_isNonDistributedArray()) then + chpl_debug_writeln("default _array accessor was called"); + if this.isRectangular() || this.isSparse() then return value.dsiAccess(i); else @@ -1030,6 +1039,10 @@ module ChapelArray { if boundsChecking then checkAccess(i, value=value); + if logAllArrEltAccess || + (logDistArrEltAccess && !chpl_isNonDistributedArray()) then + chpl_debug_writeln("default _array accessor was called"); + if this.isRectangular() || this.isSparse() then return value.dsiAccess(i); else @@ -1043,6 +1056,10 @@ module ChapelArray { if boundsChecking then checkAccess(i, value=value); + if logAllArrEltAccess || + (logDistArrEltAccess && !chpl_isNonDistributedArray()) then + chpl_debug_writeln("default _array accessor was called"); + if this.isRectangular() || this.isSparse() then return value.dsiAccess(i); else @@ -1077,6 +1094,10 @@ module ChapelArray { if boundsChecking then checkAccess(i, value=value); + if logAllArrEltAccess || + (logDistArrEltAccess && !chpl_isNonDistributedArray()) then + chpl_debug_writeln("local _array accessor was called"); + if chpl_isNonDistributedArray() then return this(i); else @@ -1094,6 +1115,10 @@ module ChapelArray { if boundsChecking then checkAccess(i, value=value); + if logAllArrEltAccess || + (logDistArrEltAccess && !chpl_isNonDistributedArray()) then + chpl_debug_writeln("local _array accessor was called"); + if chpl_isNonDistributedArray() then return this(i); else @@ -1110,6 +1135,10 @@ module ChapelArray { if boundsChecking then checkAccess(i, value=value); + if logAllArrEltAccess || + (logDistArrEltAccess && !chpl_isNonDistributedArray()) then + chpl_debug_writeln("local _array accessor was called"); + if chpl_isNonDistributedArray() then return this(i); else diff --git a/test/optimizations/autoLocalAccess/differentButAlignedDoms.chpl b/test/optimizations/autoLocalAccess/differentButAlignedDoms.chpl index ccfcb2a81a8d..81aca9419cf1 100644 --- a/test/optimizations/autoLocalAccess/differentButAlignedDoms.chpl +++ b/test/optimizations/autoLocalAccess/differentButAlignedDoms.chpl @@ -3,18 +3,6 @@ use common; var D = createDom({1..10}); var A: [D] int; -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - - { writeln("Iterand is a different symbol"); const DInner = D.expand(-1); diff --git a/test/optimizations/autoLocalAccess/differentButAlignedDoms.compopts b/test/optimizations/autoLocalAccess/differentButAlignedDoms.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/differentButAlignedDoms.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/differentButAlignedDoms.good b/test/optimizations/autoLocalAccess/differentButAlignedDoms.good index 5a61c473b1e2..c646d9e3d713 100644 --- a/test/optimizations/autoLocalAccess/differentButAlignedDoms.good +++ b/test/optimizations/autoLocalAccess/differentButAlignedDoms.good @@ -1,183 +1,183 @@ -Start analyzing forall (differentButAlignedDoms.chpl:21) -| Found loop domain (differentButAlignedDoms.chpl:20) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:21) +Start analyzing forall (differentButAlignedDoms.chpl:9) +| Found loop domain (differentButAlignedDoms.chpl:8) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:9) | -| Start analyzing call (differentButAlignedDoms.chpl:22) +| Start analyzing call (differentButAlignedDoms.chpl:10) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:22) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:10) | -End analyzing forall (differentButAlignedDoms.chpl:21) +End analyzing forall (differentButAlignedDoms.chpl:9) -Start analyzing forall (differentButAlignedDoms.chpl:31) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:31) +Start analyzing forall (differentButAlignedDoms.chpl:19) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:19) | -| Start analyzing call (differentButAlignedDoms.chpl:32) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:32) +| Start analyzing call (differentButAlignedDoms.chpl:20) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:20) | -End analyzing forall (differentButAlignedDoms.chpl:31) +End analyzing forall (differentButAlignedDoms.chpl:19) -Start analyzing forall (differentButAlignedDoms.chpl:44) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:44) +Start analyzing forall (differentButAlignedDoms.chpl:32) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:32) | -| Start analyzing call (differentButAlignedDoms.chpl:45) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:45) +| Start analyzing call (differentButAlignedDoms.chpl:33) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:33) | -End analyzing forall (differentButAlignedDoms.chpl:44) +End analyzing forall (differentButAlignedDoms.chpl:32) -Start analyzing forall (differentButAlignedDoms.chpl:50) -| Found loop domain (differentButAlignedDoms.chpl:48) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:50) +Start analyzing forall (differentButAlignedDoms.chpl:38) +| Found loop domain (differentButAlignedDoms.chpl:36) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:38) | -| Start analyzing call (differentButAlignedDoms.chpl:51) +| Start analyzing call (differentButAlignedDoms.chpl:39) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:51) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:39) | -End analyzing forall (differentButAlignedDoms.chpl:50) +End analyzing forall (differentButAlignedDoms.chpl:38) -Start analyzing forall (differentButAlignedDoms.chpl:55) -| Found loop domain (differentButAlignedDoms.chpl:54) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:55) +Start analyzing forall (differentButAlignedDoms.chpl:43) +| Found loop domain (differentButAlignedDoms.chpl:42) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:43) | -| Start analyzing call (differentButAlignedDoms.chpl:56) +| Start analyzing call (differentButAlignedDoms.chpl:44) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:56) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:44) | -End analyzing forall (differentButAlignedDoms.chpl:55) +End analyzing forall (differentButAlignedDoms.chpl:43) -Start analyzing forall (differentButAlignedDoms.chpl:44) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:44) +Start analyzing forall (differentButAlignedDoms.chpl:32) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:32) | -| Start analyzing call (differentButAlignedDoms.chpl:45) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:45) +| Start analyzing call (differentButAlignedDoms.chpl:33) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:33) | -End analyzing forall (differentButAlignedDoms.chpl:44) +End analyzing forall (differentButAlignedDoms.chpl:32) -Start analyzing forall (differentButAlignedDoms.chpl:50) -| Found loop domain (differentButAlignedDoms.chpl:48) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:50) +Start analyzing forall (differentButAlignedDoms.chpl:38) +| Found loop domain (differentButAlignedDoms.chpl:36) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:38) | -| Start analyzing call (differentButAlignedDoms.chpl:51) +| Start analyzing call (differentButAlignedDoms.chpl:39) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:51) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:39) | -End analyzing forall (differentButAlignedDoms.chpl:50) +End analyzing forall (differentButAlignedDoms.chpl:38) -Start analyzing forall (differentButAlignedDoms.chpl:55) -| Found loop domain (differentButAlignedDoms.chpl:54) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:55) +Start analyzing forall (differentButAlignedDoms.chpl:43) +| Found loop domain (differentButAlignedDoms.chpl:42) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:43) | -| Start analyzing call (differentButAlignedDoms.chpl:56) +| Start analyzing call (differentButAlignedDoms.chpl:44) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:56) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:44) | -End analyzing forall (differentButAlignedDoms.chpl:55) +End analyzing forall (differentButAlignedDoms.chpl:43) -Start analyzing forall (differentButAlignedDoms.chpl:67) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:67) +Start analyzing forall (differentButAlignedDoms.chpl:55) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:55) | -| Start analyzing call (differentButAlignedDoms.chpl:68) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:68) +| Start analyzing call (differentButAlignedDoms.chpl:56) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:56) | -End analyzing forall (differentButAlignedDoms.chpl:67) +End analyzing forall (differentButAlignedDoms.chpl:55) -Start analyzing forall (differentButAlignedDoms.chpl:73) -| Found loop domain (differentButAlignedDoms.chpl:71) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:73) +Start analyzing forall (differentButAlignedDoms.chpl:61) +| Found loop domain (differentButAlignedDoms.chpl:59) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:61) | -| Start analyzing call (differentButAlignedDoms.chpl:74) +| Start analyzing call (differentButAlignedDoms.chpl:62) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:74) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:62) | -End analyzing forall (differentButAlignedDoms.chpl:73) +End analyzing forall (differentButAlignedDoms.chpl:61) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:22) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:32) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:45) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:51) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:10) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:20) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:33) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:39) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:44) Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:56) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:68) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:74) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:62) Iterand is a different symbol -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 0 2 3 4 5 6 7 8 9 0 Iterand is a call -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 0 2 3 4 5 6 7 8 9 0 Local subdomain patterns -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 1 4 6 8 10 12 14 16 18 10 Count based domain slices -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 1 2 3 4 5 6 7 8 9 10 diff --git a/test/optimizations/autoLocalAccess/elemAsIndex.chpl b/test/optimizations/autoLocalAccess/elemAsIndex.chpl index feb7890837ad..9e1409c26321 100644 --- a/test/optimizations/autoLocalAccess/elemAsIndex.chpl +++ b/test/optimizations/autoLocalAccess/elemAsIndex.chpl @@ -1,17 +1,5 @@ use BlockDist; -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - - var A = newBlockArr({1..10}, int); for (a,i) in zip(A, A.domain) do a=i; diff --git a/test/optimizations/autoLocalAccess/elemAsIndex.compopts b/test/optimizations/autoLocalAccess/elemAsIndex.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/elemAsIndex.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/elemAsIndex.good b/test/optimizations/autoLocalAccess/elemAsIndex.good index 96a695f2b5f0..8a27b56fc0f5 100644 --- a/test/optimizations/autoLocalAccess/elemAsIndex.good +++ b/test/optimizations/autoLocalAccess/elemAsIndex.good @@ -1,23 +1,23 @@ -Start analyzing forall (elemAsIndex.chpl:19) -| Found loop domain (elemAsIndex.chpl:15) -| Will attempt static and dynamic optimizations (elemAsIndex.chpl:19) +Start analyzing forall (elemAsIndex.chpl:7) +| Found loop domain (elemAsIndex.chpl:3) +| Will attempt static and dynamic optimizations (elemAsIndex.chpl:7) | -| Start analyzing call (elemAsIndex.chpl:20) -| Can't determine the domain of access base (elemAsIndex.chpl:15) -| This call is a dynamic optimization candidate (elemAsIndex.chpl:20) +| Start analyzing call (elemAsIndex.chpl:8) +| Can't determine the domain of access base (elemAsIndex.chpl:3) +| This call is a dynamic optimization candidate (elemAsIndex.chpl:8) | -End analyzing forall (elemAsIndex.chpl:19) +End analyzing forall (elemAsIndex.chpl:7) -Local access attempt reverted. All static checks failed or code is unreachable.(elemAsIndex.chpl:20) -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called +Local access attempt reverted. All static checks failed or code is unreachable.(elemAsIndex.chpl:8) +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called 2 4 6 8 10 12 14 16 18 20 diff --git a/test/optimizations/autoLocalAccess/flags-full.good b/test/optimizations/autoLocalAccess/flags-full.good index 064fd96a4fb6..67f46a58d753 100644 --- a/test/optimizations/autoLocalAccess/flags-full.good +++ b/test/optimizations/autoLocalAccess/flags-full.good @@ -1,46 +1,46 @@ 3 3 3 3 3 3 3 3 3 3 3 6 6 6 6 6 6 6 6 6 6 6 -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called diff --git a/test/optimizations/autoLocalAccess/flags-none.good b/test/optimizations/autoLocalAccess/flags-none.good index 64ad1b71bbc3..c9e35b7c1c2c 100644 --- a/test/optimizations/autoLocalAccess/flags-none.good +++ b/test/optimizations/autoLocalAccess/flags-none.good @@ -1,46 +1,46 @@ 3 3 3 3 3 3 3 3 3 3 3 6 6 6 6 6 6 6 6 6 6 6 -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called diff --git a/test/optimizations/autoLocalAccess/flags-staticonly.good b/test/optimizations/autoLocalAccess/flags-staticonly.good index 2a77c42b48d5..ffc3573d6b00 100644 --- a/test/optimizations/autoLocalAccess/flags-staticonly.good +++ b/test/optimizations/autoLocalAccess/flags-staticonly.good @@ -1,46 +1,46 @@ 3 3 3 3 3 3 3 3 3 3 3 6 6 6 6 6 6 6 6 6 6 6 -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called diff --git a/test/optimizations/autoLocalAccess/flags.chpl b/test/optimizations/autoLocalAccess/flags.chpl index 7df7dd9dda12..fb89bca0c8b5 100644 --- a/test/optimizations/autoLocalAccess/flags.chpl +++ b/test/optimizations/autoLocalAccess/flags.chpl @@ -3,17 +3,6 @@ use common; var A = createArr({0..10}, int); var B = createArr({0..10}, int); -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - B = 3; // A should be optimized statically diff --git a/test/optimizations/autoLocalAccess/flags.compopts b/test/optimizations/autoLocalAccess/flags.compopts index 75de28fbbea8..6648a9b96d0f 100644 --- a/test/optimizations/autoLocalAccess/flags.compopts +++ b/test/optimizations/autoLocalAccess/flags.compopts @@ -1,6 +1,6 @@ # we sort the output of these tests to make the result deterministic, there # isn't much point in collecting the compiler report ---no-report-auto-local-access --auto-local-access #flags-full ---no-report-auto-local-access --no-dynamic-auto-local-access #flags-staticonly ---no-report-auto-local-access --no-auto-local-access #flags-none +-slogDistArrEltAccess=true --no-report-auto-local-access --auto-local-access #flags-full +-slogDistArrEltAccess=true --no-report-auto-local-access --no-dynamic-auto-local-access #flags-staticonly +-slogDistArrEltAccess=true --no-report-auto-local-access --no-auto-local-access #flags-none diff --git a/test/optimizations/autoLocalAccess/localArrays-1D-COO.good b/test/optimizations/autoLocalAccess/localArrays-1D-COO.good new file mode 100644 index 000000000000..1f5d3f8b5cc0 --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays-1D-COO.good @@ -0,0 +1,18 @@ + +Start analyzing forall (localArrays.chpl:56) +| Found loop domain (localArrays.chpl:51) +| Will attempt static and dynamic optimizations (localArrays.chpl:56) +| +| Start analyzing call (localArrays.chpl:57) +| Found the domain of the access base (localArrays.chpl:51) +| Can optimize: Access base's domain is the iterator (localArrays.chpl:57) +| This call is a static optimization candidate (localArrays.chpl:57) +| +End analyzing forall (localArrays.chpl:56) + +Static check successful. Using localAccess (localArrays.chpl:57) +Testing 1D COO +2 +End testing 1D COO + +localAccess was called 2 times diff --git a/test/optimizations/autoLocalAccess/localArrays-1D-DR.good b/test/optimizations/autoLocalAccess/localArrays-1D-DR.good new file mode 100644 index 000000000000..6127ffa80b21 --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays-1D-DR.good @@ -0,0 +1,18 @@ + +Start analyzing forall (localArrays.chpl:56) +| Found loop domain (localArrays.chpl:51) +| Will attempt static and dynamic optimizations (localArrays.chpl:56) +| +| Start analyzing call (localArrays.chpl:57) +| Found the domain of the access base (localArrays.chpl:51) +| Can optimize: Access base's domain is the iterator (localArrays.chpl:57) +| This call is a static optimization candidate (localArrays.chpl:57) +| +End analyzing forall (localArrays.chpl:56) + +Static check successful. Using localAccess (localArrays.chpl:57) +Testing 1D DR +1 2 3 4 5 6 7 8 9 10 +End testing 1D DR + +localAccess was called 10 times diff --git a/test/optimizations/autoLocalAccess/localArrays-2D-COO.good b/test/optimizations/autoLocalAccess/localArrays-2D-COO.good new file mode 100644 index 000000000000..74fc6b287c1e --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays-2D-COO.good @@ -0,0 +1,20 @@ + +Start analyzing forall (localArrays.chpl:56) +| Found loop domain (localArrays.chpl:51) +| Will attempt static and dynamic optimizations (localArrays.chpl:56) +| +| Start analyzing call (localArrays.chpl:57) +| Found the domain of the access base (localArrays.chpl:51) +| Can optimize: Access base's domain is the iterator (localArrays.chpl:57) +| This call is a static optimization candidate (localArrays.chpl:57) +| +End analyzing forall (localArrays.chpl:56) + +Static check successful. Using localAccess (localArrays.chpl:57) +Testing 2D COO + +2 + +End testing 2D COO + +localAccess was called 2 times diff --git a/test/optimizations/autoLocalAccess/localArrays-2D-DR.good b/test/optimizations/autoLocalAccess/localArrays-2D-DR.good new file mode 100644 index 000000000000..e701483a0c33 --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays-2D-DR.good @@ -0,0 +1,27 @@ + +Start analyzing forall (localArrays.chpl:56) +| Found loop domain (localArrays.chpl:51) +| Will attempt static and dynamic optimizations (localArrays.chpl:56) +| +| Start analyzing call (localArrays.chpl:57) +| Found the domain of the access base (localArrays.chpl:51) +| Can optimize: Access base's domain is the iterator (localArrays.chpl:57) +| This call is a static optimization candidate (localArrays.chpl:57) +| +End analyzing forall (localArrays.chpl:56) + +Static check successful. Using localAccess (localArrays.chpl:57) +Testing 2D DR +1 1 1 1 1 1 1 1 1 1 +2 2 2 2 2 2 2 2 2 2 +3 3 3 3 3 3 3 3 3 3 +4 4 4 4 4 4 4 4 4 4 +5 5 5 5 5 5 5 5 5 5 +6 6 6 6 6 6 6 6 6 6 +7 7 7 7 7 7 7 7 7 7 +8 8 8 8 8 8 8 8 8 8 +9 9 9 9 9 9 9 9 9 9 +10 10 10 10 10 10 10 10 10 10 +End testing 2D DR + +localAccess was called 100 times diff --git a/test/optimizations/autoLocalAccess/localArrays-CSC.good b/test/optimizations/autoLocalAccess/localArrays-CSC.good new file mode 100644 index 000000000000..33685c81eb26 --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays-CSC.good @@ -0,0 +1,20 @@ + +Start analyzing forall (localArrays.chpl:56) +| Found loop domain (localArrays.chpl:51) +| Will attempt static and dynamic optimizations (localArrays.chpl:56) +| +| Start analyzing call (localArrays.chpl:57) +| Found the domain of the access base (localArrays.chpl:51) +| Can optimize: Access base's domain is the iterator (localArrays.chpl:57) +| This call is a static optimization candidate (localArrays.chpl:57) +| +End analyzing forall (localArrays.chpl:56) + +Static check successful. Using localAccess (localArrays.chpl:57) +Testing CSC +1 +2 + +End testing CSC + +localAccess was called 2 times diff --git a/test/optimizations/autoLocalAccess/localArrays-CSR.good b/test/optimizations/autoLocalAccess/localArrays-CSR.good new file mode 100644 index 000000000000..19b608ff6b3a --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays-CSR.good @@ -0,0 +1,20 @@ + +Start analyzing forall (localArrays.chpl:56) +| Found loop domain (localArrays.chpl:51) +| Will attempt static and dynamic optimizations (localArrays.chpl:56) +| +| Start analyzing call (localArrays.chpl:57) +| Found the domain of the access base (localArrays.chpl:51) +| Can optimize: Access base's domain is the iterator (localArrays.chpl:57) +| This call is a static optimization candidate (localArrays.chpl:57) +| +End analyzing forall (localArrays.chpl:56) + +Static check successful. Using localAccess (localArrays.chpl:57) +Testing CSR +1 +2 + +End testing CSR + +localAccess was called 2 times diff --git a/test/optimizations/autoLocalAccess/localArrays-assoc.good b/test/optimizations/autoLocalAccess/localArrays-assoc.good new file mode 100644 index 000000000000..c6f33e2b2860 --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays-assoc.good @@ -0,0 +1,18 @@ + +Start analyzing forall (localArrays.chpl:56) +| Found loop domain (localArrays.chpl:51) +| Will attempt static and dynamic optimizations (localArrays.chpl:56) +| +| Start analyzing call (localArrays.chpl:57) +| Found the domain of the access base (localArrays.chpl:51) +| Can optimize: Access base's domain is the iterator (localArrays.chpl:57) +| This call is a static optimization candidate (localArrays.chpl:57) +| +End analyzing forall (localArrays.chpl:56) + +Static check successful. Using localAccess (localArrays.chpl:57) +Testing associative domain with string keys +102 98 +End testing associative domain with string keys + +localAccess was called 2 times diff --git a/test/optimizations/autoLocalAccess/localArrays.chpl b/test/optimizations/autoLocalAccess/localArrays.chpl index d1a580f36e20..a2308cbcb6b2 100644 --- a/test/optimizations/autoLocalAccess/localArrays.chpl +++ b/test/optimizations/autoLocalAccess/localArrays.chpl @@ -6,88 +6,48 @@ use LayoutCS; -var thisCalls: atomic int; -var localAccessCalls: atomic int; - var baseDom1D = {1..10}; var baseDom2D = {1..10, 1..10}; -{ // DR +config param case = ""; // choose which case to test + +if case == "1D DR" { test(baseDom1D, "1D DR"); +} +if case == "2D DR" { test(baseDom2D, "2D DR"); } -{ +if case == "1D COO" { var cooDom: sparse subdomain(baseDom1D); cooDom += [1,2]; test(cooDom, "1D COO"); } -{ +if case == "2D COO" { var cooDom: sparse subdomain(baseDom2D); cooDom += [(1,1),(2,2)]; test(cooDom, "2D COO"); } -{ +if case == "CSR" { var csrDom: sparse subdomain(baseDom2D) dmapped CS(); csrDom += [(1,1),(2,2)]; test(csrDom, "CSR"); } -{ +if case == "CSC" { var cscDom: sparse subdomain(baseDom2D) dmapped CS(compressRows=false); cscDom += [(1,1),(2,2)]; test(cscDom, "CSC"); } -{ +if case == "associative domain with string keys" { var assocDom: domain(string); assocDom += ["foo", "bar"]; test(assocDom, "associative domain with string keys"); } -// hijack these methods to provide some output -inline proc _array.this(i: string) ref { - thisCalls.add(1); - return this._value.dsiAccess(i); -} - -inline proc _array.localAccess(i: string) ref { - localAccessCalls.add(1); - return this._value.dsiAccess(i); -} - -inline proc _array.this(i: int) ref { - thisCalls.add(1); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.this(i: 2*int) ref { - thisCalls.add(1); - return this._value.dsiAccess(i); -} - -inline proc _array.localAccess(i: int) ref { - localAccessCalls.add(1); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: 2*int) ref { - localAccessCalls.add(1); - return this._value.dsiAccess(i); -} - -proc resetCounters() { - thisCalls.write(0); - localAccessCalls.write(0); -} - -proc printCounters() { - writeln("Calls to `this`: ", thisCalls.read()); - writeln("Calls to `localAccess`: ", localAccessCalls.read()); -} - proc test(dom:domain, name) { writeln("Testing ", name); @@ -99,9 +59,6 @@ proc test(dom:domain, name) { writeln(arr); - printCounters(); - resetCounters(); - writeln("End testing ", name); writeln(); diff --git a/test/optimizations/autoLocalAccess/localArrays.compopts b/test/optimizations/autoLocalAccess/localArrays.compopts new file mode 100644 index 000000000000..2a2c86b7729f --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays.compopts @@ -0,0 +1,7 @@ +-scase='"1D DR"' -slogAllArrEltAccess=true # localArrays-1D-DR +-scase='"2D DR"' -slogAllArrEltAccess=true # localArrays-2D-DR +-scase='"1D COO"' -slogAllArrEltAccess=true # localArrays-1D-COO +-scase='"2D COO"' -slogAllArrEltAccess=true # localArrays-2D-COO +-scase='"CSR"' -slogAllArrEltAccess=true # localArrays-CSR +-scase='"CSC"' -slogAllArrEltAccess=true # localArrays-CSC +-scase='"associative domain with string keys"' -slogAllArrEltAccess=true #localArrays-assoc diff --git a/test/optimizations/autoLocalAccess/localArrays.good b/test/optimizations/autoLocalAccess/localArrays.good deleted file mode 100644 index d9b38ded615c..000000000000 --- a/test/optimizations/autoLocalAccess/localArrays.good +++ /dev/null @@ -1,76 +0,0 @@ - -Start analyzing forall (localArrays.chpl:96) -| Found loop domain (localArrays.chpl:91) -| Will attempt static and dynamic optimizations (localArrays.chpl:96) -| -| Start analyzing call (localArrays.chpl:97) -| Found the domain of the access base (localArrays.chpl:91) -| Can optimize: Access base's domain is the iterator (localArrays.chpl:97) -| This call is a static optimization candidate (localArrays.chpl:97) -| -End analyzing forall (localArrays.chpl:96) - -Static check successful. Using localAccess (localArrays.chpl:97) -Static check successful. Using localAccess (localArrays.chpl:97) -Static check successful. Using localAccess (localArrays.chpl:97) -Static check successful. Using localAccess (localArrays.chpl:97) -Static check successful. Using localAccess (localArrays.chpl:97) -Static check successful. Using localAccess (localArrays.chpl:97) -Static check successful. Using localAccess (localArrays.chpl:97) -Testing 1D DR -1 2 3 4 5 6 7 8 9 10 -Calls to `this`: 0 -Calls to `localAccess`: 10 -End testing 1D DR - -Testing 2D DR -1 1 1 1 1 1 1 1 1 1 -2 2 2 2 2 2 2 2 2 2 -3 3 3 3 3 3 3 3 3 3 -4 4 4 4 4 4 4 4 4 4 -5 5 5 5 5 5 5 5 5 5 -6 6 6 6 6 6 6 6 6 6 -7 7 7 7 7 7 7 7 7 7 -8 8 8 8 8 8 8 8 8 8 -9 9 9 9 9 9 9 9 9 9 -10 10 10 10 10 10 10 10 10 10 -Calls to `this`: 0 -Calls to `localAccess`: 100 -End testing 2D DR - -Testing 1D COO -1 2 -Calls to `this`: 0 -Calls to `localAccess`: 2 -End testing 1D COO - -Testing 2D COO -1 -2 - -Calls to `this`: 0 -Calls to `localAccess`: 2 -End testing 2D COO - -Testing CSR -1 -2 - -Calls to `this`: 0 -Calls to `localAccess`: 2 -End testing CSR - -Testing CSC -1 -2 - -Calls to `this`: 0 -Calls to `localAccess`: 2 -End testing CSC - -Testing associative domain with string keys -102 98 -Calls to `this`: 0 -Calls to `localAccess`: 2 -End testing associative domain with string keys - diff --git a/test/optimizations/autoLocalAccess/localArrays.prediff b/test/optimizations/autoLocalAccess/localArrays.prediff new file mode 100755 index 000000000000..385f824258d8 --- /dev/null +++ b/test/optimizations/autoLocalAccess/localArrays.prediff @@ -0,0 +1,10 @@ +#!/bin/sh + +# count 'local _array accessor was called' lines and +# count 'default _array accessor was called' +nonloc=`grep 'default _array accessor was called' $2 | wc -l` +loc=`grep 'local _array accessor was called' $2 | wc -l` + +grep -v '_array accessor was called' $2 >$2.tmp +echo localAccess was called $loc times >> $2.tmp +mv $2.tmp $2 diff --git a/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.chpl b/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.chpl index c8ac4acaccb5..b7fbe9b67fde 100644 --- a/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.chpl +++ b/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.chpl @@ -2,17 +2,6 @@ use common; class MyClass { proc this(i) { return i; } } -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - var D = createDom({1..10}); var A = createArr({1..10}, int); // dynamic candidate, static check is true diff --git a/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.good b/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.good index 6b52be19e954..a7c50b6de0fa 100644 --- a/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.good +++ b/test/optimizations/autoLocalAccess/oneStaticFailOtherDynamicSuccess.good @@ -1,28 +1,18 @@ -Start analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:23) -| Found loop domain (oneStaticFailOtherDynamicSuccess.chpl:16) -| Will attempt static and dynamic optimizations (oneStaticFailOtherDynamicSuccess.chpl:23) +Start analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:12) +| Found loop domain (oneStaticFailOtherDynamicSuccess.chpl:5) +| Will attempt static and dynamic optimizations (oneStaticFailOtherDynamicSuccess.chpl:12) | -| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:24) -| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:18) -| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:24) +| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:13) +| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:7) +| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:13) | -| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:24) -| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:19) -| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:24) +| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:13) +| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:8) +| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:13) | -End analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:23) +End analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:12) -Static check successful. Using localAccess with dynamic check (oneStaticFailOtherDynamicSuccess.chpl:24) -Static check failed. Reverting optimization [static and dynamic ALA clone] (oneStaticFailOtherDynamicSuccess.chpl:24) -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +Static check successful. Using localAccess with dynamic check (oneStaticFailOtherDynamicSuccess.chpl:13) +Static check failed. Reverting optimization [static and dynamic ALA clone] (oneStaticFailOtherDynamicSuccess.chpl:13) 1 2 3 4 5 6 7 8 9 10 diff --git a/test/optimizations/autoLocalAccess/preventMultiCall.chpl b/test/optimizations/autoLocalAccess/preventMultiCall.chpl index b38711388b52..7538011f6080 100644 --- a/test/optimizations/autoLocalAccess/preventMultiCall.chpl +++ b/test/optimizations/autoLocalAccess/preventMultiCall.chpl @@ -7,18 +7,6 @@ proc returnDom() { return createDom({1..10}); } -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - - var A = createArr({1..10}, int); var B = createArr({1..10}, int); var C = createArr({1..10}, int); diff --git a/test/optimizations/autoLocalAccess/preventMultiCall.compopts b/test/optimizations/autoLocalAccess/preventMultiCall.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/preventMultiCall.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/preventMultiCall.good b/test/optimizations/autoLocalAccess/preventMultiCall.good index 5392b5249536..704ec4ae25c7 100644 --- a/test/optimizations/autoLocalAccess/preventMultiCall.good +++ b/test/optimizations/autoLocalAccess/preventMultiCall.good @@ -1,50 +1,50 @@ -Start analyzing forall (preventMultiCall.chpl:29) -| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCall.chpl:29) +Start analyzing forall (preventMultiCall.chpl:17) +| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCall.chpl:17) | -| Start analyzing call (preventMultiCall.chpl:30) -| This call is a dynamic optimization candidate (preventMultiCall.chpl:30) +| Start analyzing call (preventMultiCall.chpl:18) +| This call is a dynamic optimization candidate (preventMultiCall.chpl:18) | -| Start analyzing call (preventMultiCall.chpl:31) -| This call is a dynamic optimization candidate (preventMultiCall.chpl:31) +| Start analyzing call (preventMultiCall.chpl:19) +| This call is a dynamic optimization candidate (preventMultiCall.chpl:19) | -| Start analyzing call (preventMultiCall.chpl:32) -| This call is a dynamic optimization candidate (preventMultiCall.chpl:32) +| Start analyzing call (preventMultiCall.chpl:20) +| This call is a dynamic optimization candidate (preventMultiCall.chpl:20) | -End analyzing forall (preventMultiCall.chpl:29) +End analyzing forall (preventMultiCall.chpl:17) -Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:30) -Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:31) -Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:32) +Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:18) +Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:19) +Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:20) returnDom is called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 3 3 3 3 3 3 3 3 3 3 diff --git a/test/optimizations/autoLocalAccess/preventMultiCallIter.chpl b/test/optimizations/autoLocalAccess/preventMultiCallIter.chpl index 64a453cee49a..b0451a889fe5 100644 --- a/test/optimizations/autoLocalAccess/preventMultiCallIter.chpl +++ b/test/optimizations/autoLocalAccess/preventMultiCallIter.chpl @@ -1,6 +1,6 @@ // The forall here cannot be optimized. But we must make sure that we are not // doing anything funny with the iterator to make that decision - +use common; // we must have exactly one iterator invocation (the automatic localaccess // optimization shouldn't create another iterator record) iter myIter() { @@ -25,20 +25,9 @@ iter myIter(param tag: iterKind, followThis) where tag == iterKind.follower { for i in followThis[0] do yield i; } -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - -var A: [1..10] int; -var B: [1..10] int; -var C: [1..10] int; +var A = createArr({1..10}, int); +var B = createArr({1..10}, int); +var C = createArr({1..10}, int); B = 1; C = 2; diff --git a/test/optimizations/autoLocalAccess/preventMultiCallIter.compopts b/test/optimizations/autoLocalAccess/preventMultiCallIter.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/preventMultiCallIter.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/preventMultiCallIter.good b/test/optimizations/autoLocalAccess/preventMultiCallIter.good index 3ea43f49befa..52be8b583659 100644 --- a/test/optimizations/autoLocalAccess/preventMultiCallIter.good +++ b/test/optimizations/autoLocalAccess/preventMultiCallIter.good @@ -1,50 +1,50 @@ -Start analyzing forall (preventMultiCallIter.chpl:46) -| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCallIter.chpl:46) +Start analyzing forall (preventMultiCallIter.chpl:35) +| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCallIter.chpl:35) | -| Start analyzing call (preventMultiCallIter.chpl:47) -| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:47) +| Start analyzing call (preventMultiCallIter.chpl:36) +| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:36) | -| Start analyzing call (preventMultiCallIter.chpl:48) -| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:48) +| Start analyzing call (preventMultiCallIter.chpl:37) +| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:37) | -| Start analyzing call (preventMultiCallIter.chpl:49) -| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:49) +| Start analyzing call (preventMultiCallIter.chpl:38) +| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:38) | -End analyzing forall (preventMultiCallIter.chpl:46) +End analyzing forall (preventMultiCallIter.chpl:35) -Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:47) -Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:48) -Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:49) +Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:36) +Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:37) +Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:38) standalone iterator invoked -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called 3 3 3 3 3 3 3 3 3 3 diff --git a/test/optimizations/autoLocalAccess/views.chpl b/test/optimizations/autoLocalAccess/views.chpl index a5c4dbcf8525..d70ac046188d 100644 --- a/test/optimizations/autoLocalAccess/views.chpl +++ b/test/optimizations/autoLocalAccess/views.chpl @@ -1,26 +1,5 @@ use common; -var thisCalls: atomic int; -var localAccessCalls: atomic int; -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - //writeln("Custom this was called"); - thisCalls.add(1); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.this(i: int, j: int) ref { - //writeln("Custom this was called"); - thisCalls.add(1); - return this._value.dsiAccess((i:int,j:int)); -} - -inline proc _array.localAccess(i: int) ref { - //writeln("Custom localAccess was called"); - localAccessCalls.add(1); - return this._value.dsiLocalAccess((i:int,)); -} - writeln(); writeln("Starting"); @@ -111,7 +90,3 @@ writeln("Starting"); writeln(A); writeln(); } - - -writeln("`this` was called ", thisCalls , " times"); -writeln("`localAccess` was called ", localAccessCalls, " times"); diff --git a/test/optimizations/autoLocalAccess/views.compopts b/test/optimizations/autoLocalAccess/views.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/views.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/views.good b/test/optimizations/autoLocalAccess/views.good index ab36ccac68a4..f984a888b142 100644 --- a/test/optimizations/autoLocalAccess/views.good +++ b/test/optimizations/autoLocalAccess/views.good @@ -1,66 +1,66 @@ +Start analyzing forall (views.chpl:19) +| Found loop domain (views.chpl:9) +| Will attempt static and dynamic optimizations (views.chpl:19) +| +| Start analyzing call (views.chpl:20) +| Found the domain of the access base (views.chpl:8) +| This call is a dynamic optimization candidate (views.chpl:20) +| +| Start analyzing call (views.chpl:21) +| Can't determine the domain of access base (views.chpl:14) +| This call is a dynamic optimization candidate (views.chpl:21) +| +End analyzing forall (views.chpl:19) + + Start analyzing forall (views.chpl:40) -| Found loop domain (views.chpl:30) +| Found loop domain (views.chpl:32) | Will attempt static and dynamic optimizations (views.chpl:40) | -| Start analyzing call (views.chpl:41) -| Found the domain of the access base (views.chpl:29) -| This call is a dynamic optimization candidate (views.chpl:41) -| | Start analyzing call (views.chpl:42) +| Can optimize: Access base is the iterator's base (views.chpl:42) +| This call is a static optimization candidate (views.chpl:42) +| +| Start analyzing call (views.chpl:43) | Can't determine the domain of access base (views.chpl:35) -| This call is a dynamic optimization candidate (views.chpl:42) +| This call is a dynamic optimization candidate (views.chpl:43) | End analyzing forall (views.chpl:40) -Start analyzing forall (views.chpl:61) -| Found loop domain (views.chpl:53) -| Will attempt static and dynamic optimizations (views.chpl:61) -| -| Start analyzing call (views.chpl:63) -| Can optimize: Access base is the iterator's base (views.chpl:63) -| This call is a static optimization candidate (views.chpl:63) +Start analyzing forall (views.chpl:63) +| Found loop domain (views.chpl:59) +| Will attempt static and dynamic optimizations (views.chpl:63) | | Start analyzing call (views.chpl:64) -| Can't determine the domain of access base (views.chpl:56) -| This call is a dynamic optimization candidate (views.chpl:64) +| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:64) +| Start analyzing call (views.chpl:65) +| Can optimize: Access base is the iterator's base (views.chpl:65) +| This call is a static optimization candidate (views.chpl:65) | -End analyzing forall (views.chpl:61) +End analyzing forall (views.chpl:63) -Start analyzing forall (views.chpl:84) -| Found loop domain (views.chpl:80) -| Will attempt static and dynamic optimizations (views.chpl:84) +Start analyzing forall (views.chpl:85) +| Found loop domain (views.chpl:83) +| Will attempt static and dynamic optimizations (views.chpl:85) | -| Start analyzing call (views.chpl:85) -| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:85) | Start analyzing call (views.chpl:86) | Can optimize: Access base is the iterator's base (views.chpl:86) | This call is a static optimization candidate (views.chpl:86) | -End analyzing forall (views.chpl:84) - - -Start analyzing forall (views.chpl:106) -| Found loop domain (views.chpl:104) -| Will attempt static and dynamic optimizations (views.chpl:106) -| -| Start analyzing call (views.chpl:107) -| Can optimize: Access base is the iterator's base (views.chpl:107) -| This call is a static optimization candidate (views.chpl:107) -| -| Start analyzing call (views.chpl:108) -| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:108) -End analyzing forall (views.chpl:106) +| Start analyzing call (views.chpl:87) +| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:87) +End analyzing forall (views.chpl:85) -Static check successful. Using localAccess with dynamic check (views.chpl:41) -Static check successful. Using localAccess with dynamic check (views.chpl:42) -Static check successful. Using localAccess [static and dynamic ALA clone] (views.chpl:63) -Static check successful. Using localAccess with dynamic check (views.chpl:64) -Static check successful. Using localAccess [static only ALA clone] (views.chpl:63) -Static check successful. Using localAccess [static only ALA clone] (views.chpl:107) -Local access attempt reverted. All static checks failed or code is unreachable.(views.chpl:86) +Static check successful. Using localAccess with dynamic check (views.chpl:20) +Static check successful. Using localAccess with dynamic check (views.chpl:21) +Static check successful. Using localAccess [static and dynamic ALA clone] (views.chpl:42) +Static check successful. Using localAccess with dynamic check (views.chpl:43) +Static check successful. Using localAccess [static only ALA clone] (views.chpl:42) +Static check successful. Using localAccess [static only ALA clone] (views.chpl:86) +Local access attempt reverted. All static checks failed or code is unreachable.(views.chpl:65) Starting Slice: using slicing domain @@ -84,5 +84,5 @@ Rank change 0 0 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 -`this` was called 30 times -`localAccess` was called 42 times +this was called 30 times +localAccess was called 42 times diff --git a/test/optimizations/autoLocalAccess/views.prediff b/test/optimizations/autoLocalAccess/views.prediff new file mode 100755 index 000000000000..c03385756eb1 --- /dev/null +++ b/test/optimizations/autoLocalAccess/views.prediff @@ -0,0 +1,11 @@ +#!/bin/sh + +# count 'local _array accessor was called' lines and +# count 'default _array accessor was called' +nonloc=`grep 'default _array accessor was called' $2 | wc -l` +loc=`grep 'local _array accessor was called' $2 | wc -l` + +grep -v '_array accessor was called' $2 >$2.tmp +echo this was called $nonloc times >> $2.tmp +echo localAccess was called $loc times >> $2.tmp +mv $2.tmp $2 diff --git a/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.chpl b/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.chpl index f32281e119cf..f226b12b4bb5 100644 --- a/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.chpl +++ b/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.chpl @@ -3,18 +3,6 @@ use common; var D = createDom({1..10}); var A: [D] int; -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - - { writeln("Iterand is a different symbol"); const DInner = D.expand(-1); diff --git a/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.compopts b/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.good b/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.good index d20fbc3c8f21..60f90a0a309b 100644 --- a/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.good +++ b/test/optimizations/autoLocalAccess/zipper/differentButAlignedDoms.good @@ -1,183 +1,183 @@ -Start analyzing forall (differentButAlignedDoms.chpl:21) -| Found loop domain (differentButAlignedDoms.chpl:20) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:21) +Start analyzing forall (differentButAlignedDoms.chpl:9) +| Found loop domain (differentButAlignedDoms.chpl:8) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:9) | -| Start analyzing call (differentButAlignedDoms.chpl:22) +| Start analyzing call (differentButAlignedDoms.chpl:10) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:22) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:10) | -End analyzing forall (differentButAlignedDoms.chpl:21) +End analyzing forall (differentButAlignedDoms.chpl:9) -Start analyzing forall (differentButAlignedDoms.chpl:31) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:31) +Start analyzing forall (differentButAlignedDoms.chpl:19) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:19) | -| Start analyzing call (differentButAlignedDoms.chpl:32) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:32) +| Start analyzing call (differentButAlignedDoms.chpl:20) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:20) | -End analyzing forall (differentButAlignedDoms.chpl:31) +End analyzing forall (differentButAlignedDoms.chpl:19) -Start analyzing forall (differentButAlignedDoms.chpl:44) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:44) +Start analyzing forall (differentButAlignedDoms.chpl:32) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:32) | -| Start analyzing call (differentButAlignedDoms.chpl:45) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:45) +| Start analyzing call (differentButAlignedDoms.chpl:33) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:33) | -End analyzing forall (differentButAlignedDoms.chpl:44) +End analyzing forall (differentButAlignedDoms.chpl:32) -Start analyzing forall (differentButAlignedDoms.chpl:50) -| Found loop domain (differentButAlignedDoms.chpl:48) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:50) +Start analyzing forall (differentButAlignedDoms.chpl:38) +| Found loop domain (differentButAlignedDoms.chpl:36) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:38) | -| Start analyzing call (differentButAlignedDoms.chpl:51) +| Start analyzing call (differentButAlignedDoms.chpl:39) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:51) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:39) | -End analyzing forall (differentButAlignedDoms.chpl:50) +End analyzing forall (differentButAlignedDoms.chpl:38) -Start analyzing forall (differentButAlignedDoms.chpl:55) -| Found loop domain (differentButAlignedDoms.chpl:54) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:55) +Start analyzing forall (differentButAlignedDoms.chpl:43) +| Found loop domain (differentButAlignedDoms.chpl:42) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:43) | -| Start analyzing call (differentButAlignedDoms.chpl:56) +| Start analyzing call (differentButAlignedDoms.chpl:44) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:56) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:44) | -End analyzing forall (differentButAlignedDoms.chpl:55) +End analyzing forall (differentButAlignedDoms.chpl:43) -Start analyzing forall (differentButAlignedDoms.chpl:44) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:44) +Start analyzing forall (differentButAlignedDoms.chpl:32) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:32) | -| Start analyzing call (differentButAlignedDoms.chpl:45) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:45) +| Start analyzing call (differentButAlignedDoms.chpl:33) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:33) | -End analyzing forall (differentButAlignedDoms.chpl:44) +End analyzing forall (differentButAlignedDoms.chpl:32) -Start analyzing forall (differentButAlignedDoms.chpl:50) -| Found loop domain (differentButAlignedDoms.chpl:48) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:50) +Start analyzing forall (differentButAlignedDoms.chpl:38) +| Found loop domain (differentButAlignedDoms.chpl:36) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:38) | -| Start analyzing call (differentButAlignedDoms.chpl:51) +| Start analyzing call (differentButAlignedDoms.chpl:39) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:51) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:39) | -End analyzing forall (differentButAlignedDoms.chpl:50) +End analyzing forall (differentButAlignedDoms.chpl:38) -Start analyzing forall (differentButAlignedDoms.chpl:55) -| Found loop domain (differentButAlignedDoms.chpl:54) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:55) +Start analyzing forall (differentButAlignedDoms.chpl:43) +| Found loop domain (differentButAlignedDoms.chpl:42) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:43) | -| Start analyzing call (differentButAlignedDoms.chpl:56) +| Start analyzing call (differentButAlignedDoms.chpl:44) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:56) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:44) | -End analyzing forall (differentButAlignedDoms.chpl:55) +End analyzing forall (differentButAlignedDoms.chpl:43) -Start analyzing forall (differentButAlignedDoms.chpl:67) -| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:67) +Start analyzing forall (differentButAlignedDoms.chpl:55) +| Couldn't determine loop domain: will attempt dynamic optimizations only (differentButAlignedDoms.chpl:55) | -| Start analyzing call (differentButAlignedDoms.chpl:68) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:68) +| Start analyzing call (differentButAlignedDoms.chpl:56) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:56) | -End analyzing forall (differentButAlignedDoms.chpl:67) +End analyzing forall (differentButAlignedDoms.chpl:55) -Start analyzing forall (differentButAlignedDoms.chpl:73) -| Found loop domain (differentButAlignedDoms.chpl:71) -| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:73) +Start analyzing forall (differentButAlignedDoms.chpl:61) +| Found loop domain (differentButAlignedDoms.chpl:59) +| Will attempt static and dynamic optimizations (differentButAlignedDoms.chpl:61) | -| Start analyzing call (differentButAlignedDoms.chpl:74) +| Start analyzing call (differentButAlignedDoms.chpl:62) | Found the domain of the access base (differentButAlignedDoms.chpl:3) -| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:74) +| This call is a dynamic optimization candidate (differentButAlignedDoms.chpl:62) | -End analyzing forall (differentButAlignedDoms.chpl:73) +End analyzing forall (differentButAlignedDoms.chpl:61) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:22) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:32) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:45) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:51) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:10) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:20) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:33) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:39) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:44) Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:56) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:68) -Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:74) +Static check successful. Using localAccess with dynamic check (differentButAlignedDoms.chpl:62) Iterand is a different symbol -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 0 100 101 102 103 104 105 106 107 0 Iterand is a call -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 0 100 101 102 103 104 105 106 107 0 Local subdomain patterns -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 100 201 203 205 207 209 211 213 215 109 Count based domain slices -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 100 101 102 103 104 105 106 107 108 109 diff --git a/test/optimizations/autoLocalAccess/zipper/elemAsIndex.chpl b/test/optimizations/autoLocalAccess/zipper/elemAsIndex.chpl index 58b92dcb690a..b223f09ce2a2 100644 --- a/test/optimizations/autoLocalAccess/zipper/elemAsIndex.chpl +++ b/test/optimizations/autoLocalAccess/zipper/elemAsIndex.chpl @@ -1,17 +1,5 @@ use BlockDist; -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - - var A = newBlockArr({1..10}, int); for (a,i) in zip(A, A.domain) do a=i; diff --git a/test/optimizations/autoLocalAccess/zipper/elemAsIndex.compopts b/test/optimizations/autoLocalAccess/zipper/elemAsIndex.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/zipper/elemAsIndex.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/zipper/elemAsIndex.good b/test/optimizations/autoLocalAccess/zipper/elemAsIndex.good index 1790e08cf9ec..50c8a6d0e17f 100644 --- a/test/optimizations/autoLocalAccess/zipper/elemAsIndex.good +++ b/test/optimizations/autoLocalAccess/zipper/elemAsIndex.good @@ -1,23 +1,23 @@ -Start analyzing forall (elemAsIndex.chpl:19) -| Found loop domain (elemAsIndex.chpl:15) -| Will attempt static and dynamic optimizations (elemAsIndex.chpl:19) +Start analyzing forall (elemAsIndex.chpl:7) +| Found loop domain (elemAsIndex.chpl:3) +| Will attempt static and dynamic optimizations (elemAsIndex.chpl:7) | -| Start analyzing call (elemAsIndex.chpl:20) -| Can't determine the domain of access base (elemAsIndex.chpl:15) -| This call is a dynamic optimization candidate (elemAsIndex.chpl:20) +| Start analyzing call (elemAsIndex.chpl:8) +| Can't determine the domain of access base (elemAsIndex.chpl:3) +| This call is a dynamic optimization candidate (elemAsIndex.chpl:8) | -End analyzing forall (elemAsIndex.chpl:19) +End analyzing forall (elemAsIndex.chpl:7) -Local access attempt reverted. All static checks failed or code is unreachable.(elemAsIndex.chpl:20) -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called +Local access attempt reverted. All static checks failed or code is unreachable.(elemAsIndex.chpl:8) +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called 1 4 9 16 25 36 49 64 81 100 diff --git a/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.chpl b/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.chpl index 916cbc9f3146..3cdecebb02de 100644 --- a/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.chpl +++ b/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.chpl @@ -2,17 +2,6 @@ use common; class MyClass { proc this(i) { return i; } } -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - var D = createDom({1..10}); var A = createArr({1..10}, int); // dynamic candidate, static check is true diff --git a/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.compopts b/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.good b/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.good index c1d9fcc876c8..50bda8098373 100644 --- a/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.good +++ b/test/optimizations/autoLocalAccess/zipper/oneStaticFailOtherDynamicSuccess.good @@ -1,28 +1,28 @@ -Start analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:23) -| Found loop domain (oneStaticFailOtherDynamicSuccess.chpl:16) -| Will attempt static and dynamic optimizations (oneStaticFailOtherDynamicSuccess.chpl:23) +Start analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:12) +| Found loop domain (oneStaticFailOtherDynamicSuccess.chpl:5) +| Will attempt static and dynamic optimizations (oneStaticFailOtherDynamicSuccess.chpl:12) | -| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:24) -| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:18) -| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:24) +| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:13) +| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:7) +| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:13) | -| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:24) -| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:19) -| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:24) +| Start analyzing call (oneStaticFailOtherDynamicSuccess.chpl:13) +| Can't determine the domain of access base (oneStaticFailOtherDynamicSuccess.chpl:8) +| This call is a dynamic optimization candidate (oneStaticFailOtherDynamicSuccess.chpl:13) | -End analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:23) +End analyzing forall (oneStaticFailOtherDynamicSuccess.chpl:12) -Static check successful. Using localAccess with dynamic check (oneStaticFailOtherDynamicSuccess.chpl:24) -Static check failed. Reverting optimization [static and dynamic ALA clone] (oneStaticFailOtherDynamicSuccess.chpl:24) -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +Static check successful. Using localAccess with dynamic check (oneStaticFailOtherDynamicSuccess.chpl:13) +Static check failed. Reverting optimization [static and dynamic ALA clone] (oneStaticFailOtherDynamicSuccess.chpl:13) +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 1 4 9 16 25 36 49 64 81 100 diff --git a/test/optimizations/autoLocalAccess/zipper/preventMultiCall.chpl b/test/optimizations/autoLocalAccess/zipper/preventMultiCall.chpl index 5af189728213..f3d47dc8265a 100644 --- a/test/optimizations/autoLocalAccess/zipper/preventMultiCall.chpl +++ b/test/optimizations/autoLocalAccess/zipper/preventMultiCall.chpl @@ -7,18 +7,6 @@ proc returnDom() { return createDom({1..10}); } -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - - var A = createArr({1..10}, int); var B = createArr({1..10}, int); var C = createArr({1..10}, int); diff --git a/test/optimizations/autoLocalAccess/zipper/preventMultiCall.compopts b/test/optimizations/autoLocalAccess/zipper/preventMultiCall.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/zipper/preventMultiCall.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/zipper/preventMultiCall.good b/test/optimizations/autoLocalAccess/zipper/preventMultiCall.good index b8eb11a54471..a033c3a9ca30 100644 --- a/test/optimizations/autoLocalAccess/zipper/preventMultiCall.good +++ b/test/optimizations/autoLocalAccess/zipper/preventMultiCall.good @@ -1,50 +1,50 @@ -Start analyzing forall (preventMultiCall.chpl:29) -| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCall.chpl:29) +Start analyzing forall (preventMultiCall.chpl:17) +| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCall.chpl:17) | -| Start analyzing call (preventMultiCall.chpl:30) -| This call is a dynamic optimization candidate (preventMultiCall.chpl:30) +| Start analyzing call (preventMultiCall.chpl:18) +| This call is a dynamic optimization candidate (preventMultiCall.chpl:18) | -| Start analyzing call (preventMultiCall.chpl:31) -| This call is a dynamic optimization candidate (preventMultiCall.chpl:31) +| Start analyzing call (preventMultiCall.chpl:19) +| This call is a dynamic optimization candidate (preventMultiCall.chpl:19) | -| Start analyzing call (preventMultiCall.chpl:32) -| This call is a dynamic optimization candidate (preventMultiCall.chpl:32) +| Start analyzing call (preventMultiCall.chpl:20) +| This call is a dynamic optimization candidate (preventMultiCall.chpl:20) | -End analyzing forall (preventMultiCall.chpl:29) +End analyzing forall (preventMultiCall.chpl:17) -Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:30) -Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:31) -Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:32) +Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:18) +Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:19) +Static check successful. Using localAccess with dynamic check (preventMultiCall.chpl:20) returnDom is called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called -Custom localAccess was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called +local _array accessor was called 103 104 105 106 107 108 109 110 111 112 diff --git a/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.chpl b/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.chpl index be9d9c147970..fe5e05af3b49 100644 --- a/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.chpl +++ b/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.chpl @@ -1,6 +1,6 @@ // The forall here cannot be optimized. But we must make sure that we are not // doing anything funny with the iterator to make that decision - +use common; // we must have exactly one iterator invocation (the automatic localaccess // optimization shouldn't create another iterator record) iter myIter() { @@ -25,21 +25,9 @@ iter myIter(param tag: iterKind, followThis) where tag == iterKind.follower { for i in followThis[0] do yield i; } -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - writeln("Custom this was called"); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.localAccess(i: int) ref { - writeln("Custom localAccess was called"); - return this._value.dsiLocalAccess((i:int,)); -} - - -var A: [1..10] int; -var B: [1..10] int; -var C: [1..10] int; +var A = createArr({1..10}, int); +var B = createArr({1..10}, int); +var C = createArr({1..10}, int); B = 1; C = 2; diff --git a/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.compopts b/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.good b/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.good index b0c082c1f327..d6d799192d56 100644 --- a/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.good +++ b/test/optimizations/autoLocalAccess/zipper/preventMultiCallIter.good @@ -1,51 +1,51 @@ -Start analyzing forall (preventMultiCallIter.chpl:47) -| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCallIter.chpl:47) +Start analyzing forall (preventMultiCallIter.chpl:35) +| Couldn't determine loop domain: will attempt dynamic optimizations only (preventMultiCallIter.chpl:35) | -| Start analyzing call (preventMultiCallIter.chpl:48) -| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:48) +| Start analyzing call (preventMultiCallIter.chpl:36) +| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:36) | -| Start analyzing call (preventMultiCallIter.chpl:49) -| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:49) +| Start analyzing call (preventMultiCallIter.chpl:37) +| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:37) | -| Start analyzing call (preventMultiCallIter.chpl:50) -| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:50) +| Start analyzing call (preventMultiCallIter.chpl:38) +| This call is a dynamic optimization candidate (preventMultiCallIter.chpl:38) | -End analyzing forall (preventMultiCallIter.chpl:47) +End analyzing forall (preventMultiCallIter.chpl:35) -Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:48) -Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:49) -Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:50) +Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:36) +Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:37) +Local access attempt reverted. All static checks failed or code is unreachable.(preventMultiCallIter.chpl:38) leader iterator invoked follower iterator invoked -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called -Custom this was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called +default _array accessor was called 6 7 8 9 10 11 12 13 14 15 diff --git a/test/optimizations/autoLocalAccess/zipper/views.chpl b/test/optimizations/autoLocalAccess/zipper/views.chpl index 26c2499bdfb5..d27dbc0c2024 100644 --- a/test/optimizations/autoLocalAccess/zipper/views.chpl +++ b/test/optimizations/autoLocalAccess/zipper/views.chpl @@ -1,26 +1,5 @@ use common; -var thisCalls: atomic int; -var localAccessCalls: atomic int; -// hijack these two methods to provide some output -inline proc _array.this(i: int) ref { - //writeln("Custom this was called"); - thisCalls.add(1); - return this._value.dsiAccess((i:int,)); -} - -inline proc _array.this(i: int, j: int) ref { - //writeln("Custom this was called"); - thisCalls.add(1); - return this._value.dsiAccess((i:int,j:int)); -} - -inline proc _array.localAccess(i: int) ref { - //writeln("Custom localAccess was called"); - localAccessCalls.add(1); - return this._value.dsiLocalAccess((i:int,)); -} - writeln(); writeln("Starting"); @@ -111,7 +90,3 @@ writeln("Starting"); writeln(A); writeln(); } - - -writeln("`this` was called ", thisCalls , " times"); -writeln("`localAccess` was called ", localAccessCalls, " times"); diff --git a/test/optimizations/autoLocalAccess/zipper/views.compopts b/test/optimizations/autoLocalAccess/zipper/views.compopts new file mode 100644 index 000000000000..f04593945e8f --- /dev/null +++ b/test/optimizations/autoLocalAccess/zipper/views.compopts @@ -0,0 +1 @@ +-slogDistArrEltAccess=true diff --git a/test/optimizations/autoLocalAccess/zipper/views.good b/test/optimizations/autoLocalAccess/zipper/views.good index e2180ac616e6..0b34ba515a1f 100644 --- a/test/optimizations/autoLocalAccess/zipper/views.good +++ b/test/optimizations/autoLocalAccess/zipper/views.good @@ -1,66 +1,66 @@ +Start analyzing forall (views.chpl:19) +| Found loop domain (views.chpl:9) +| Will attempt static and dynamic optimizations (views.chpl:19) +| +| Start analyzing call (views.chpl:20) +| Found the domain of the access base (views.chpl:8) +| This call is a dynamic optimization candidate (views.chpl:20) +| +| Start analyzing call (views.chpl:21) +| Can't determine the domain of access base (views.chpl:14) +| This call is a dynamic optimization candidate (views.chpl:21) +| +End analyzing forall (views.chpl:19) + + Start analyzing forall (views.chpl:40) -| Found loop domain (views.chpl:30) +| Found loop domain (views.chpl:32) | Will attempt static and dynamic optimizations (views.chpl:40) | -| Start analyzing call (views.chpl:41) -| Found the domain of the access base (views.chpl:29) -| This call is a dynamic optimization candidate (views.chpl:41) -| | Start analyzing call (views.chpl:42) +| Can optimize: Access base is the iterator's base (views.chpl:42) +| This call is a static optimization candidate (views.chpl:42) +| +| Start analyzing call (views.chpl:43) | Can't determine the domain of access base (views.chpl:35) -| This call is a dynamic optimization candidate (views.chpl:42) +| This call is a dynamic optimization candidate (views.chpl:43) | End analyzing forall (views.chpl:40) -Start analyzing forall (views.chpl:61) -| Found loop domain (views.chpl:53) -| Will attempt static and dynamic optimizations (views.chpl:61) -| -| Start analyzing call (views.chpl:63) -| Can optimize: Access base is the iterator's base (views.chpl:63) -| This call is a static optimization candidate (views.chpl:63) +Start analyzing forall (views.chpl:63) +| Found loop domain (views.chpl:59) +| Will attempt static and dynamic optimizations (views.chpl:63) | | Start analyzing call (views.chpl:64) -| Can't determine the domain of access base (views.chpl:56) -| This call is a dynamic optimization candidate (views.chpl:64) +| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:64) +| Start analyzing call (views.chpl:65) +| Can optimize: Access base is the iterator's base (views.chpl:65) +| This call is a static optimization candidate (views.chpl:65) | -End analyzing forall (views.chpl:61) +End analyzing forall (views.chpl:63) -Start analyzing forall (views.chpl:84) -| Found loop domain (views.chpl:80) -| Will attempt static and dynamic optimizations (views.chpl:84) +Start analyzing forall (views.chpl:85) +| Found loop domain (views.chpl:83) +| Will attempt static and dynamic optimizations (views.chpl:85) | -| Start analyzing call (views.chpl:85) -| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:85) | Start analyzing call (views.chpl:86) | Can optimize: Access base is the iterator's base (views.chpl:86) | This call is a static optimization candidate (views.chpl:86) | -End analyzing forall (views.chpl:84) - - -Start analyzing forall (views.chpl:106) -| Found loop domain (views.chpl:104) -| Will attempt static and dynamic optimizations (views.chpl:106) -| -| Start analyzing call (views.chpl:107) -| Can optimize: Access base is the iterator's base (views.chpl:107) -| This call is a static optimization candidate (views.chpl:107) -| -| Start analyzing call (views.chpl:108) -| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:108) -End analyzing forall (views.chpl:106) +| Start analyzing call (views.chpl:87) +| Cannot optimize: call arguments don't match loop indices cleanly (views.chpl:87) +End analyzing forall (views.chpl:85) -Static check successful. Using localAccess with dynamic check (views.chpl:41) -Static check successful. Using localAccess with dynamic check (views.chpl:42) -Static check successful. Using localAccess [static and dynamic ALA clone] (views.chpl:63) -Static check successful. Using localAccess with dynamic check (views.chpl:64) -Static check successful. Using localAccess [static only ALA clone] (views.chpl:63) -Static check successful. Using localAccess [static only ALA clone] (views.chpl:107) -Local access attempt reverted. All static checks failed or code is unreachable.(views.chpl:86) +Static check successful. Using localAccess with dynamic check (views.chpl:20) +Static check successful. Using localAccess with dynamic check (views.chpl:21) +Static check successful. Using localAccess [static and dynamic ALA clone] (views.chpl:42) +Static check successful. Using localAccess with dynamic check (views.chpl:43) +Static check successful. Using localAccess [static only ALA clone] (views.chpl:42) +Static check successful. Using localAccess [static only ALA clone] (views.chpl:86) +Local access attempt reverted. All static checks failed or code is unreachable.(views.chpl:65) Starting Slice: using slicing domain @@ -84,5 +84,5 @@ Rank change 0 0 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 -`this` was called 30 times -`localAccess` was called 42 times +this was called 30 times +localAccess was called 42 times diff --git a/test/optimizations/autoLocalAccess/zipper/views.prediff b/test/optimizations/autoLocalAccess/zipper/views.prediff new file mode 120000 index 000000000000..06e6c365808f --- /dev/null +++ b/test/optimizations/autoLocalAccess/zipper/views.prediff @@ -0,0 +1 @@ +../views.prediff \ No newline at end of file From 393e94be1a5a82afe79902c37b8b45cc1176a76e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 9 May 2022 14:49:40 -0400 Subject: [PATCH 94/96] Address Lydia's feedback --- Signed-off-by: Michael Ferguson --- compiler/resolution/resolveFunction.cpp | 14 +++++++------- doc/rst/language/spec/modules.rst | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index e4af318b9538..02c83a5014b1 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -95,15 +95,15 @@ void resolveSignatureAndFunction(FnSymbol* fn) { ************************************** | *************************************/ void resolveSignature(FnSymbol* fn) { - // Don't resolve formals for concrete functions - // more often than necessary. - static std::set done; + // Don't resolve formals for concrete functions + // more often than necessary. + static std::set done; - if (done.find(fn) == done.end()) { - done.insert(fn); + if (done.find(fn) == done.end()) { + done.insert(fn); - resolveFormals(fn); - } + resolveFormals(fn); + } } /************************************* | ************************************** diff --git a/doc/rst/language/spec/modules.rst b/doc/rst/language/spec/modules.rst index 6e72f2f1120a..34b816f983a2 100644 --- a/doc/rst/language/spec/modules.rst +++ b/doc/rst/language/spec/modules.rst @@ -336,7 +336,7 @@ statement can be at any position relative to the ``use`` or ``import``. Private ``use`` statements -- for example ``use M`` or ``private use M`` - make the contents of the module available in a scope just outside of -the current one and the name of the module itself (``M`` in the xample) +the current one and the name of the module itself (``M`` in the example) available in a second scope just outside of that. In contrast, ``import`` as well as ``public use`` do not use these implicit scopes. @@ -367,7 +367,7 @@ statement. The symbols that are shadowed will only be accessible via } module MainMod { - use A; + private use A; // note: 'use A' means the same as 'private use A' var x = "hello"; proc main() { @@ -376,9 +376,9 @@ statement. The symbols that are shadowed will only be accessible via } This program will compile and print out ``hello`` because the use of - ``x`` refers to ``MainMod.x`` which shadows ``A.x`` because ``use A``, - which means the same as ``private use A``, introduces ``x`` in a scope - just outside of the scope of ``MainMod``. + ``x`` refers to ``MainMod.x`` which shadows ``A.x`` because ``private + use A`` introduces ``x`` in a scope just outside of the scope of + ``MainMod``. .. code-block:: printoutput From 4e73421abc1da6d1ede317d067aa345669ccf595 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 10 May 2022 09:02:56 -0400 Subject: [PATCH 95/96] Revert "Allow error for overloading assignment for c_string" This reverts commit 711348fbb947d30acdf26192ea2195c9b54d6ea0. --- Signed-off-by: Michael Ferguson --- test/functions/sungeun/procEquals_c_string.good | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functions/sungeun/procEquals_c_string.good b/test/functions/sungeun/procEquals_c_string.good index 3f5380aa5516..e69de29bb2d1 100644 --- a/test/functions/sungeun/procEquals_c_string.good +++ b/test/functions/sungeun/procEquals_c_string.good @@ -1 +0,0 @@ -procEquals_c_string.chpl:1: error: Can't overload assignments for class types From 5403f88bfe5a79554d86c339a190b75a90a7ea9d Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 10 May 2022 10:18:50 -0400 Subject: [PATCH 96/96] Fix up comments in new tests --- Signed-off-by: Michael Ferguson --- test/modules/shadowing/issue-19352-2a.chpl | 2 +- test/modules/shadowing/issue-19352-2b.chpl | 2 +- test/modules/shadowing/issue-19352-3.chpl | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/modules/shadowing/issue-19352-2a.chpl b/test/modules/shadowing/issue-19352-2a.chpl index ecd53cf031ce..9f3deae017e5 100644 --- a/test/modules/shadowing/issue-19352-2a.chpl +++ b/test/modules/shadowing/issue-19352-2a.chpl @@ -13,6 +13,6 @@ module Program { proc main() { var r = new Library.rec(); - r.method(); // currently outputs: Program's rec.method() + r.method(); // currently, ambiguity } } diff --git a/test/modules/shadowing/issue-19352-2b.chpl b/test/modules/shadowing/issue-19352-2b.chpl index aad951313a39..49575c20aaad 100644 --- a/test/modules/shadowing/issue-19352-2b.chpl +++ b/test/modules/shadowing/issue-19352-2b.chpl @@ -13,6 +13,6 @@ module Program { proc main() { var r = new Library.rec(); - r.method(); // currently outputs: Program's rec.method() + r.method(); // currently, ambiguity } } diff --git a/test/modules/shadowing/issue-19352-3.chpl b/test/modules/shadowing/issue-19352-3.chpl index 17c853190ec6..257f5678b761 100644 --- a/test/modules/shadowing/issue-19352-3.chpl +++ b/test/modules/shadowing/issue-19352-3.chpl @@ -19,8 +19,6 @@ module Program { proc main() { var r = new Library.rec(); - r.method(); // currently: - // without PR #19306, ambiguity error - // with PR #19306, outputs LibraryPlus's rec.method() + r.method(); // currently, ambiguity } }