From b7ebf2ceff05a779fab13e78b3e2c15c24369b30 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 14 Sep 2023 17:30:53 -0400 Subject: [PATCH 01/35] Add warning for shadowing with public vs private use --- Signed-off-by: Michael Ferguson --- .../resolution-error-classes-list.h | 1 + .../include/chpl/resolution/scope-queries.h | 14 ++ frontend/lib/resolution/Resolver.cpp | 5 +- .../resolution-error-classes-list.cpp | 20 +++ frontend/lib/resolution/scope-queries.cpp | 139 +++++++++++++++--- 5 files changed, 158 insertions(+), 21 deletions(-) diff --git a/frontend/include/chpl/resolution/resolution-error-classes-list.h b/frontend/include/chpl/resolution/resolution-error-classes-list.h index 5ecfebf05b82..01fe71ed1aa5 100644 --- a/frontend/include/chpl/resolution/resolution-error-classes-list.h +++ b/frontend/include/chpl/resolution/resolution-error-classes-list.h @@ -60,6 +60,7 @@ ERROR_CLASS(NestedClassFieldRef, const uast::AggregateDecl*, const uast::Aggrega ERROR_CLASS(NonIterable, const uast::AstNode*, const uast::AstNode*, types::QualifiedType) ERROR_CLASS(NotInModule, const uast::Dot*, ID, UniqueString, ID, bool) ERROR_CLASS(PhaseTwoInitMarker, const uast::AstNode*, std::vector) +WARNING_CLASS(PotentiallySurprisingShadowing, ID, UniqueString, const resolution::Scope*, int, std::vector) ERROR_CLASS(PrivateToPublicInclude, const uast::Include*, const uast::Module*) ERROR_CLASS(ProcDefExplicitAnonFormal, const uast::Function*, const uast::Formal*) ERROR_CLASS(ProcTypeUnannotatedFormal, const uast::FunctionSignature*, const uast::AnonFormal*) diff --git a/frontend/include/chpl/resolution/scope-queries.h b/frontend/include/chpl/resolution/scope-queries.h index bdb18de63852..f8dba7d77fa1 100644 --- a/frontend/include/chpl/resolution/scope-queries.h +++ b/frontend/include/chpl/resolution/scope-queries.h @@ -66,6 +66,20 @@ namespace resolution { UniqueString name, LookupConfig config); + /** + Same as lookupNameInScope but can produce warnings based on + the ID passed in. + */ + + std::vector + lookupNameInScopeWithWarnings(Context* context, + const Scope* scope, + llvm::ArrayRef receiverScopes, + UniqueString name, + LookupConfig config, + ID idForWarnings); + + /** Same as lookupNameInScope but traces how each symbol was found, for error messages. diff --git a/frontend/lib/resolution/Resolver.cpp b/frontend/lib/resolution/Resolver.cpp index f625b4fbe3ea..5509a8867d69 100644 --- a/frontend/lib/resolution/Resolver.cpp +++ b/frontend/lib/resolution/Resolver.cpp @@ -2405,8 +2405,9 @@ Resolver::lookupIdentifier(const Identifier* ident, if (!resolvingCalledIdent) config |= LOOKUP_INNERMOST; - auto vec = - lookupNameInScope(context, scope, receiverScopes, ident->name(), config); + auto vec = lookupNameInScopeWithWarnings(context, scope, receiverScopes, + ident->name(), config, + ident->id()); bool notFound = vec.empty(); bool ambiguous = !notFound && (vec.size() > 1 || vec[0].numIds() > 1); diff --git a/frontend/lib/resolution/resolution-error-classes-list.cpp b/frontend/lib/resolution/resolution-error-classes-list.cpp index 0f412fda9aff..24acaf12281c 100644 --- a/frontend/lib/resolution/resolution-error-classes-list.cpp +++ b/frontend/lib/resolution/resolution-error-classes-list.cpp @@ -760,6 +760,26 @@ void ErrorPhaseTwoInitMarker::write(ErrorWriterBase& wr) const { wr.code(previousMarker, { previousMarker }); } +void ErrorPotentiallySurprisingShadowing::write(ErrorWriterBase& wr) const { + auto id = std::get(info); + auto name = std::get(info); + auto shadowStart = std::get(info); + auto& matches = std::get>(info); + + wr.heading(kind_, type_, id, + "potentially surprising shadowing for '", name.c_str(), "'"); + wr.code(id, { id }); + // only print out two matches + if (matches.size() > 0 && matches.size() > (size_t) shadowStart) { + ID first = matches[0].firstId(); + ID shadowed = matches[shadowStart].firstId(); + wr.note(first, "it refers to the symbol declared here"); + wr.code(first, { first }); + wr.note(shadowed, "because this symbol can only be found through a shadow scope"); + wr.code(shadowed, { shadowed }); + } +} + void ErrorPrivateToPublicInclude::write(ErrorWriterBase& wr) const { auto moduleInclude = std::get(info); auto moduleDef = std::get(info); diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index a2f84471273e..bd0308d09b63 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -485,6 +485,16 @@ const Scope* scopeForId(Context* context, ID id) { using VisibilityTraceElt = ResultVisibilityTrace::VisibilityTraceElt; +/* +struct AdditionalResults { + const Scope* scope = nullptr; + std::vector results; + AdditionalResults(const Scope* scope, + std::vector results) + : scope(scope), results(std::move(results)) + { } +};*/ + // a struct to encapsulate arguments to doLookupIn... // so that the calls and function signatures do not get too unwieldy. struct LookupHelper { @@ -495,6 +505,14 @@ struct LookupHelper { bool& foundExternBlock; std::vector* traceCurPath; std::vector* traceResult; + const ID* idForWarnings; + // set this if we've completed a LOOKUP_INNERMOST search, + // but we want to search additional shadow scopes for the purpose + // of emitting a warning if there is suprising shadowing occuring. + // if it is set, additional results go into additionalResultsForWarning + // instead of 'result'. + //ssize_t firstResultForWarning = -1; + //std::vector additionalResultsForWarning; LookupHelper(Context* context, const ResolvedVisibilityScope* resolving, @@ -502,10 +520,13 @@ struct LookupHelper { std::vector& result, bool& foundExternBlock, std::vector* traceCurPath, - std::vector* traceResult) - : context(context), resolving(resolving), checkedScopes(checkedScopes), + std::vector* traceResult, + const ID* idForWarnings) + : context(context), resolving(resolving), + checkedScopes(checkedScopes), result(result), foundExternBlock(foundExternBlock), - traceCurPath(traceCurPath), traceResult(traceResult) { + traceCurPath(traceCurPath), traceResult(traceResult), + idForWarnings(idForWarnings) { } bool doLookupInImportsAndUses(const Scope* scope, @@ -1064,6 +1085,16 @@ bool LookupHelper::doLookupInScope(const Scope* scope, } } + bool canCheckMoreForWarning = onlyInnermost && !skipShadowScopes && + idForWarnings != nullptr; + bool checkMoreForWarning = false; + size_t firstResultForWarning = 0; + //ssize_t oldFirstResultForWarning = firstResultForWarning; + + if (idForWarnings && idForWarnings->str() == "Application@3" && + scope->id().str() == "Application") + gdbShouldBreakHere(); + // gather non-shadow scope information // (declarations in this scope as well as public use / import) { @@ -1080,11 +1111,18 @@ bool LookupHelper::doLookupInScope(const Scope* scope, } } if (checkUseImport) { + bool gotLocalDecls = got; got |= doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, VisibilitySymbols::REGULAR_SCOPE); + if (got && !gotLocalDecls && canCheckMoreForWarning) { + // if we only found it in a 'public use' etc, + // check the shadow scopes in addition, to potentially warn. + checkMoreForWarning = true; + firstResultForWarning = result.size(); + } } - if (onlyInnermost && got) return true; + if (onlyInnermost && got && !checkMoreForWarning) return true; } // now check shadow scope 1 (only relevant for 'private use') @@ -1100,7 +1138,11 @@ bool LookupHelper::doLookupInScope(const Scope* scope, skipPrivateVisibilities, onlyMethodsFields, includeMethods); - if (onlyInnermost && got) return true; + if (got && canCheckMoreForWarning && !checkMoreForWarning) { + checkMoreForWarning = true; + firstResultForWarning = result.size(); + } + if (onlyInnermost && got && !checkMoreForWarning) return true; } // now check shadow scope 2 (only relevant for 'private use') @@ -1109,7 +1151,33 @@ bool LookupHelper::doLookupInScope(const Scope* scope, got = doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, VisibilitySymbols::SHADOW_SCOPE_TWO); - if (onlyInnermost && got) return true; + if (got && canCheckMoreForWarning && !checkMoreForWarning) { + checkMoreForWarning = true; + firstResultForWarning = result.size(); + } + if (onlyInnermost && got && !checkMoreForWarning) return true; + } + + if (checkMoreForWarning) { + // move results after firstResultForWarning to additionalResultsForWarning + /*std::vector additionalResults; + additionalResults.insert(additionalResults.end(), + result.begin() + firstResultForWarning, + result.end()); + additionalResultsForWarning.push_back( + AdditionalResults(scope, std::move(additionalResults)));*/ + + if (firstResultForWarning < result.size()) { + CHPL_REPORT(context, PotentiallySurprisingShadowing, + *idForWarnings, name, scope, + (int) firstResultForWarning, result); + result.erase(result.begin() + firstResultForWarning, result.end()); + } + + // restore firstResultForWarning to its previous value, now that + // the shadow scopes have been considered. + //firstResultForWarning = oldFirstResultForWarning; + return true; } // If we are at a method scope, consider receiver scopes now @@ -1241,6 +1309,7 @@ static bool lookupInScopeViz(Context* context, const Scope* scope, const ResolvedVisibilityScope* resolving, UniqueString name, + ID idForWarnings, VisibilityStmtKind useOrImport, bool isFirstPart, std::vector& result, @@ -1279,10 +1348,11 @@ static bool lookupInScopeViz(Context* context, } bool foundExternBlock = false; // ignored - auto helper = LookupHelper(context, resolving, checkedScopes, result, - foundExternBlock, + auto helper = LookupHelper(context, resolving, + checkedScopes, result, foundExternBlock, /* traceCurPath */ nullptr, - /* traceResult */ nullptr); + /* traceResult */ nullptr, + &idForWarnings); got = helper.doLookupInScope(scope, {}, name, config); } @@ -1309,7 +1379,8 @@ static bool lookupInScopeViz(Context* context, improperMatches, foundExternBlock, /* traceCurPath */ nullptr, - /* traceResult */ nullptr); + /* traceResult */ nullptr, + &idForWarnings); helper.doLookupInScope(scope, {}, name, config); } @@ -1325,7 +1396,8 @@ static bool helpLookupInScope(Context* context, CheckedScopes& checkedScopes, std::vector& result, std::vector* traceCurPath, - std::vector* traceResult) + std::vector* traceResult, + const ID* idForWarnings) { bool onlyInnermost = (config & LOOKUP_INNERMOST) != 0; bool checkExternBlocks = (config & LOOKUP_EXTERN_BLOCKS) != 0; @@ -1333,7 +1405,8 @@ static bool helpLookupInScope(Context* context, CheckedScopes savedCheckedScopes; auto helper = LookupHelper(context, resolving, checkedScopes, result, - foundExternBlock, traceCurPath, traceResult); + foundExternBlock, traceCurPath, traceResult, + idForWarnings); if (checkExternBlocks) { // clear the extern blocks lookup (since it is a 2nd pass) @@ -1380,7 +1453,30 @@ lookupNameInScope(Context* context, /* resolving scope */ nullptr, name, config, visited, vec, /* traceCurPath */ nullptr, - /* traceResult */ nullptr); + /* traceResult */ nullptr, + /* idForWarnings */ nullptr); + } + + return vec; +} + +std::vector +lookupNameInScopeWithWarnings(Context* context, + const Scope* scope, + llvm::ArrayRef receiverScopes, + UniqueString name, + LookupConfig config, + ID idForWarnings) { + CheckedScopes visited; + std::vector vec; + + if (scope) { + helpLookupInScope(context, scope, receiverScopes, + /* resolving scope */ nullptr, + name, config, visited, vec, + /* traceCurPath */ nullptr, + /* traceResult */ nullptr, + &idForWarnings); } return vec; @@ -1401,7 +1497,8 @@ lookupNameInScopeTracing(Context* context, /* resolving scope */ nullptr, name, config, visited, vec, &traceCurPath, - &traceResult); + &traceResult, + /* idForWarnings */ nullptr); } return vec; @@ -1422,7 +1519,8 @@ lookupNameInScopeWithSet(Context* context, /* resolving scope */ nullptr, name, config, visited, vec, /* traceCurPath */ nullptr, - /* traceResult */ nullptr); + /* traceResult */ nullptr, + /* idForWarnings */ nullptr); } return vec; @@ -1513,7 +1611,8 @@ static void errorIfNameNotInScope(Context* context, bool got = helpLookupInScope(context, scope, {}, resolving, name, config, checkedScopes, result, /* traceCurPath */ nullptr, - /* traceResult */ nullptr); + /* traceResult */ nullptr, + /* idForWarnings */ nullptr); bool found = got && result.size() > 0; bool foundViaPrivate = false; @@ -1531,7 +1630,8 @@ static void errorIfNameNotInScope(Context* context, bool got = helpLookupInScope(context, scope, {}, resolving, name, config, checkedScopes, result, /* traceCurPath */ nullptr, - /* traceResult */ nullptr); + /* traceResult */ nullptr, + /* idForWarnings */ nullptr); found = got && result.size() > 0; @@ -1748,7 +1848,7 @@ static const Scope* findScopeViz(Context* context, const Scope* scope, // lookup 'field' in that scope std::vector vec; std::vector improperMatches; - bool got = lookupInScopeViz(context, scope, resolving, nameInScope, + bool got = lookupInScopeViz(context, scope, resolving, nameInScope, idForErrs, useOrImport, isFirstPart, vec, improperMatches); // We might've discovered the same ID multiple times, via different @@ -2299,7 +2399,8 @@ static const bool& warnHiddenFormalsQuery(Context* context, auto helper = LookupHelper(context, rs, checkedScopes, matches, foundExternBlock, /* traceCurPath */ nullptr, - /* traceResult */ nullptr); + /* traceResult */ nullptr, + /* idForWarnings */ nullptr); got = helper.doLookupInScope(rs->scope(), {}, name, config); From 31e6760b20cf02479924f072886ad06fe60d5d85 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 21 Sep 2023 17:26:50 -0400 Subject: [PATCH 02/35] Pull warning out of doLookupInScope to other helpers, tune error --- Signed-off-by: Michael Ferguson --- .../resolution-error-classes-list.h | 2 +- .../resolution-error-classes-list.cpp | 49 ++- frontend/lib/resolution/scope-queries.cpp | 289 ++++++++++-------- 3 files changed, 192 insertions(+), 148 deletions(-) diff --git a/frontend/include/chpl/resolution/resolution-error-classes-list.h b/frontend/include/chpl/resolution/resolution-error-classes-list.h index 01fe71ed1aa5..c26c714017bc 100644 --- a/frontend/include/chpl/resolution/resolution-error-classes-list.h +++ b/frontend/include/chpl/resolution/resolution-error-classes-list.h @@ -60,7 +60,7 @@ ERROR_CLASS(NestedClassFieldRef, const uast::AggregateDecl*, const uast::Aggrega ERROR_CLASS(NonIterable, const uast::AstNode*, const uast::AstNode*, types::QualifiedType) ERROR_CLASS(NotInModule, const uast::Dot*, ID, UniqueString, ID, bool) ERROR_CLASS(PhaseTwoInitMarker, const uast::AstNode*, std::vector) -WARNING_CLASS(PotentiallySurprisingShadowing, ID, UniqueString, const resolution::Scope*, int, std::vector) +WARNING_CLASS(PotentiallySurprisingShadowing, ID, UniqueString, std::vector, std::vector, std::vector, std::vector) ERROR_CLASS(PrivateToPublicInclude, const uast::Include*, const uast::Module*) ERROR_CLASS(ProcDefExplicitAnonFormal, const uast::Function*, const uast::Formal*) ERROR_CLASS(ProcTypeUnannotatedFormal, const uast::FunctionSignature*, const uast::AnonFormal*) diff --git a/frontend/lib/resolution/resolution-error-classes-list.cpp b/frontend/lib/resolution/resolution-error-classes-list.cpp index 24acaf12281c..141a9ba59a7e 100644 --- a/frontend/lib/resolution/resolution-error-classes-list.cpp +++ b/frontend/lib/resolution/resolution-error-classes-list.cpp @@ -73,7 +73,6 @@ static const char* allowedItems(resolution::VisibilityStmtKind kind) { // // 'start' indicates where in the trace to start, since sometimes // the first element might have already been printed. -// 'oneOnly' indicates that only the 1st match should be described // // 'intro' will be emitted before the first message for a trace // (only relevant if start==0). If it is not empty, it should probably @@ -761,22 +760,48 @@ void ErrorPhaseTwoInitMarker::write(ErrorWriterBase& wr) const { } void ErrorPotentiallySurprisingShadowing::write(ErrorWriterBase& wr) const { - auto id = std::get(info); - auto name = std::get(info); - auto shadowStart = std::get(info); - auto& matches = std::get>(info); + auto id = std::get<0>(info); + auto name = std::get<1>(info); + auto& result = std::get<2>(info); + auto& traceResult = std::get<3>(info); + auto& shadowed = std::get<4>(info); + auto& traceShadowed = std::get<5>(info); wr.heading(kind_, type_, id, "potentially surprising shadowing for '", name.c_str(), "'"); wr.code(id, { id }); // only print out two matches - if (matches.size() > 0 && matches.size() > (size_t) shadowStart) { - ID first = matches[0].firstId(); - ID shadowed = matches[shadowStart].firstId(); - wr.note(first, "it refers to the symbol declared here"); - wr.code(first, { first }); - wr.note(shadowed, "because this symbol can only be found through a shadow scope"); - wr.code(shadowed, { shadowed }); + if (result.size() > 0 && shadowed.size() > 0) { + const char* intro = "it refers to a symbol found "; + bool encounteredAutoModule = false; + UniqueString from; + bool needsIntroText = false; + + ID firstId = result[0].firstId(); + + describeSymbolTrace(wr, id, name, + traceResult[0], /* start */ 0, intro, + encounteredAutoModule, from, needsIntroText); + + if (needsIntroText) { + wr.note(locationOnly(firstId), "it refers to the symbol '", from, "' defined here:"); + } else { + wr.note(locationOnly(firstId), "leading to '", from, "' defined here:"); + } + wr.code(firstId, { firstId }); + + const char* intro2 = "but there is a shadowed symbol found "; + describeSymbolTrace(wr, id, name, + traceShadowed[0], /* start */ 0, intro2, + encounteredAutoModule, from, needsIntroText); + + ID otherId = shadowed[0].firstId(); + if (needsIntroText) { + wr.note(locationOnly(otherId), "but there is a shadowed symbol '", from, "' defined here:"); + } else { + wr.note(locationOnly(otherId), "leading to '", from, "' defined here:"); + } + wr.code(otherId, { otherId }); } } diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index bd0308d09b63..2beafd5b1222 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -485,34 +485,18 @@ const Scope* scopeForId(Context* context, ID id) { using VisibilityTraceElt = ResultVisibilityTrace::VisibilityTraceElt; -/* -struct AdditionalResults { - const Scope* scope = nullptr; - std::vector results; - AdditionalResults(const Scope* scope, - std::vector results) - : scope(scope), results(std::move(results)) - { } -};*/ - // a struct to encapsulate arguments to doLookupIn... // so that the calls and function signatures do not get too unwieldy. struct LookupHelper { - Context* context; - const ResolvedVisibilityScope* resolving; + Context* context = nullptr; + const ResolvedVisibilityScope* resolving = nullptr; CheckedScopes& checkedScopes; std::vector& result; bool& foundExternBlock; - std::vector* traceCurPath; - std::vector* traceResult; - const ID* idForWarnings; - // set this if we've completed a LOOKUP_INNERMOST search, - // but we want to search additional shadow scopes for the purpose - // of emitting a warning if there is suprising shadowing occuring. - // if it is set, additional results go into additionalResultsForWarning - // instead of 'result'. - //ssize_t firstResultForWarning = -1; - //std::vector additionalResultsForWarning; + std::vector* traceCurPath = nullptr; + std::vector* traceResult = nullptr; + std::vector* shadowedResults = nullptr; + std::vector* traceShadowedResults = nullptr; LookupHelper(Context* context, const ResolvedVisibilityScope* resolving, @@ -521,12 +505,14 @@ struct LookupHelper { bool& foundExternBlock, std::vector* traceCurPath, std::vector* traceResult, - const ID* idForWarnings) + std::vector* shadowedResults, + std::vector* traceShadowedResults) : context(context), resolving(resolving), checkedScopes(checkedScopes), result(result), foundExternBlock(foundExternBlock), traceCurPath(traceCurPath), traceResult(traceResult), - idForWarnings(idForWarnings) { + shadowedResults(shadowedResults), + traceShadowedResults(traceShadowedResults) { } bool doLookupInImportsAndUses(const Scope* scope, @@ -1086,14 +1072,9 @@ bool LookupHelper::doLookupInScope(const Scope* scope, } bool canCheckMoreForWarning = onlyInnermost && !skipShadowScopes && - idForWarnings != nullptr; + shadowedResults != nullptr; bool checkMoreForWarning = false; size_t firstResultForWarning = 0; - //ssize_t oldFirstResultForWarning = firstResultForWarning; - - if (idForWarnings && idForWarnings->str() == "Application@3" && - scope->id().str() == "Application") - gdbShouldBreakHere(); // gather non-shadow scope information // (declarations in this scope as well as public use / import) @@ -1159,24 +1140,32 @@ bool LookupHelper::doLookupInScope(const Scope* scope, } if (checkMoreForWarning) { - // move results after firstResultForWarning to additionalResultsForWarning - /*std::vector additionalResults; - additionalResults.insert(additionalResults.end(), - result.begin() + firstResultForWarning, - result.end()); - additionalResultsForWarning.push_back( - AdditionalResults(scope, std::move(additionalResults)));*/ + // we are going to return before considering other scopes, + // but we wish to warn if there is also a match in a toplevel module, + // so check that now. + if (checkToplevel) { + doLookupInToplevelModules(scope, name); + } if (firstResultForWarning < result.size()) { - CHPL_REPORT(context, PotentiallySurprisingShadowing, - *idForWarnings, name, scope, - (int) firstResultForWarning, result); + // move results after firstResultForWarning to shadowedResults + // and similarly move traceResults + for (size_t i = firstResultForWarning; i < result.size(); i++) { + shadowedResults->push_back(std::move(result[i])); + if (trace && traceShadowedResults) { + traceShadowedResults->push_back(std::move((*traceResult)[i])); + } + } + result.erase(result.begin() + firstResultForWarning, result.end()); + if (trace) { + traceResult->erase(traceResult->begin() + firstResultForWarning, + traceResult->end()); + } } - // restore firstResultForWarning to its previous value, now that - // the shadow scopes have been considered. - //firstResultForWarning = oldFirstResultForWarning; + // either way, stop now that we have completed searching the + // additional scopes we wanted to check for the warning. return true; } @@ -1298,6 +1287,108 @@ bool LookupHelper::doLookupInScope(const Scope* scope, return result.size() > startSize; } +static bool +helpLookupInScope(Context* context, + const Scope* scope, + llvm::ArrayRef receiverScopes, + const ResolvedVisibilityScope* resolving, + UniqueString name, + LookupConfig config, + CheckedScopes& checkedScopes, + std::vector& result, + std::vector* traceCurPath=nullptr, + std::vector* traceResult=nullptr, + std::vector* shadowed=nullptr, + std::vector* traceShadowed=nullptr) +{ + bool onlyInnermost = (config & LOOKUP_INNERMOST) != 0; + bool checkExternBlocks = (config & LOOKUP_EXTERN_BLOCKS) != 0; + bool foundExternBlock = false; + CheckedScopes savedCheckedScopes; + + auto helper = LookupHelper(context, resolving, checkedScopes, result, + foundExternBlock, + traceCurPath, traceResult, + shadowed, traceShadowed); + + if (checkExternBlocks) { + // clear the extern blocks lookup (since it is a 2nd pass) + config &= ~LOOKUP_EXTERN_BLOCKS; + // make a note of the checked scopes so we can reset it + savedCheckedScopes = checkedScopes; + } + + bool got = false; + + got |= helper.doLookupInScope(scope, receiverScopes, name, config); + + // When resolving a Dot expression like myRecord.foo, we might not be inside + // of a method at all, but we should still search the definition point + // of the relevant record. + if (!receiverScopes.empty() && !(got && onlyInnermost)) { + got |= helper.doLookupInReceiverScopes(scope, receiverScopes, name, config); + } + + // If we found any extern blocks, and there were no other symbols, + // and extern block lookup was requested, use extern block lookup. + if (checkExternBlocks && !got && foundExternBlock) { + config |= LOOKUP_EXTERN_BLOCKS; + checkedScopes = savedCheckedScopes; + got = helper.doLookupInScope(scope, receiverScopes, name, config); + } + + // TODO: check for "last resort" symbols here, as well + + return got; +} + +// similar to helpLookupInScope but also emits a shadowing warning +// in some cases. +static bool helpLookupInScopeWithShadowingWarning( + Context* context, + const Scope* scope, + llvm::ArrayRef receiverScopes, + const ResolvedVisibilityScope* resolving, + UniqueString name, + LookupConfig config, + CheckedScopes& checkedScopes, + std::vector& vec, + ID idForWarnings) { + + CheckedScopes checkedScopesForRetry = checkedScopes; + std::vector shadowed; + + bool got = helpLookupInScope(context, scope, receiverScopes, resolving, + name, config, checkedScopes, vec, + /* traceCurPath */ nullptr, + /* traceResult */ nullptr, + &shadowed, + /* traceShadowed */ nullptr); + + if (shadowed.size() > 0) { + // once more, with feeling! + // well, tracing, actually. + shadowed.clear(); + std::vector result; + std::vector traceResult; + std::vector traceShadowed; + std::vector traceCurPath; + + helpLookupInScope(context, scope, receiverScopes, resolving, + name, config, checkedScopesForRetry, result, + &traceCurPath, &traceResult, + &shadowed, &traceShadowed); + + // issue a warning! + CHPL_REPORT(context, PotentiallySurprisingShadowing, + idForWarnings, name, + result, traceResult, + shadowed, traceShadowed); + } + + return got; +} + // This function supports scope lookup when resolving what modules // a 'use' / 'import' refer to. // @@ -1318,7 +1409,6 @@ static bool lookupInScopeViz(Context* context, { CheckedScopes checkedScopes; - LookupConfig config = LOOKUP_INNERMOST; // e.g. A in use A.B.C or import A.B.C @@ -1347,13 +1437,11 @@ static bool lookupInScopeViz(Context* context, config |= LOOKUP_DECLS; } - bool foundExternBlock = false; // ignored - auto helper = LookupHelper(context, resolving, - checkedScopes, result, foundExternBlock, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - &idForWarnings); - got = helper.doLookupInScope(scope, {}, name, config); + got = helpLookupInScopeWithShadowingWarning( + context, scope, /* receiverScopes */ {}, + resolving, name, config, + checkedScopes, result, + idForWarnings); } if (!got && isFirstPart) { @@ -1374,68 +1462,11 @@ static bool lookupInScopeViz(Context* context, // check for submodules of the current module, even if we're an import config |= LOOKUP_DECLS; - bool foundExternBlock = false; // ignored - auto helper = LookupHelper(context, resolving, checkedScopes, - improperMatches, - foundExternBlock, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - &idForWarnings); - helper.doLookupInScope(scope, {}, name, config); - } - - return got; -} - -static bool helpLookupInScope(Context* context, - const Scope* scope, - llvm::ArrayRef receiverScopes, - const ResolvedVisibilityScope* resolving, - UniqueString name, - LookupConfig config, - CheckedScopes& checkedScopes, - std::vector& result, - std::vector* traceCurPath, - std::vector* traceResult, - const ID* idForWarnings) -{ - bool onlyInnermost = (config & LOOKUP_INNERMOST) != 0; - bool checkExternBlocks = (config & LOOKUP_EXTERN_BLOCKS) != 0; - bool foundExternBlock = false; - CheckedScopes savedCheckedScopes; - - auto helper = LookupHelper(context, resolving, checkedScopes, result, - foundExternBlock, traceCurPath, traceResult, - idForWarnings); - - if (checkExternBlocks) { - // clear the extern blocks lookup (since it is a 2nd pass) - config &= ~LOOKUP_EXTERN_BLOCKS; - // make a note of the checked scopes so we can reset it - savedCheckedScopes = checkedScopes; - } - - bool got = false; - - got |= helper.doLookupInScope(scope, receiverScopes, name, config); - - // When resolving a Dot expression like myRecord.foo, we might not be inside - // of a method at all, but we should still search the definition point - // of the relevant record. - if (!receiverScopes.empty() && !(got && onlyInnermost)) { - got |= helper.doLookupInReceiverScopes(scope, receiverScopes, name, config); + helpLookupInScope(context, scope, /* receiverScopes */ {}, + resolving, name, config, + checkedScopes, improperMatches); } - // If we found any extern blocks, and there were no other symbols, - // and extern block lookup was requested, use extern block lookup. - if (checkExternBlocks && !got && foundExternBlock) { - config |= LOOKUP_EXTERN_BLOCKS; - checkedScopes = savedCheckedScopes; - got = helper.doLookupInScope(scope, receiverScopes, name, config); - } - - // TODO: check for "last resort" symbols here, as well - return got; } @@ -1451,10 +1482,7 @@ lookupNameInScope(Context* context, if (scope) { helpLookupInScope(context, scope, receiverScopes, /* resolving scope */ nullptr, - name, config, visited, vec, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - /* idForWarnings */ nullptr); + name, config, visited, vec); } return vec; @@ -1471,12 +1499,10 @@ lookupNameInScopeWithWarnings(Context* context, std::vector vec; if (scope) { - helpLookupInScope(context, scope, receiverScopes, - /* resolving scope */ nullptr, - name, config, visited, vec, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - &idForWarnings); + helpLookupInScopeWithShadowingWarning(context, scope, receiverScopes, + /* resolving scope */ nullptr, + name, config, visited, vec, + idForWarnings); } return vec; @@ -1498,7 +1524,8 @@ lookupNameInScopeTracing(Context* context, name, config, visited, vec, &traceCurPath, &traceResult, - /* idForWarnings */ nullptr); + /* shadowed */ nullptr, + /* traceShadowed */ nullptr); } return vec; @@ -1517,10 +1544,7 @@ lookupNameInScopeWithSet(Context* context, if (scope) { helpLookupInScope(context, scope, receiverScopes, /* resolving scope */ nullptr, - name, config, visited, vec, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - /* idForWarnings */ nullptr); + name, config, visited, vec); } return vec; @@ -1609,10 +1633,7 @@ static void errorIfNameNotInScope(Context* context, LOOKUP_SKIP_PRIVATE_VIS; bool got = helpLookupInScope(context, scope, {}, resolving, name, config, - checkedScopes, result, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - /* idForWarnings */ nullptr); + checkedScopes, result); bool found = got && result.size() > 0; bool foundViaPrivate = false; @@ -1628,10 +1649,7 @@ static void errorIfNameNotInScope(Context* context, config &= ~LOOKUP_SKIP_PRIVATE_VIS; bool got = helpLookupInScope(context, scope, {}, resolving, name, config, - checkedScopes, result, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - /* idForWarnings */ nullptr); + checkedScopes, result); found = got && result.size() > 0; @@ -2400,7 +2418,8 @@ static const bool& warnHiddenFormalsQuery(Context* context, foundExternBlock, /* traceCurPath */ nullptr, /* traceResult */ nullptr, - /* idForWarnings */ nullptr); + /* shadowedResults */ nullptr, + /* traceShadowedResults */ nullptr); got = helper.doLookupInScope(rs->scope(), {}, name, config); From 1f1dde3069fb280f78cfee7ca826d84c67f53aaa Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 22 Sep 2023 15:49:08 -0400 Subject: [PATCH 03/35] Improve the warning * consider all parent scopes (& toplevel modules) * skip the warning for e.g. 'use Dist' bringing in a symbol Dist that shadows the module Dist. --- Signed-off-by: Michael Ferguson --- frontend/lib/resolution/scope-queries.cpp | 109 ++++++++++++++-------- 1 file changed, 70 insertions(+), 39 deletions(-) diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 2beafd5b1222..39b2e479ed0b 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -521,7 +521,9 @@ struct LookupHelper { LookupConfig config, IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet& excludeFilter, - VisibilitySymbols::ShadowScope shadowScope); + VisibilitySymbols::ShadowScope shadowScope, + std::unordered_set* foundInClauses, + std::unordered_set* ignoreClauses); bool doLookupInAutoModules(const Scope* scope, UniqueString name, @@ -590,7 +592,9 @@ bool LookupHelper::doLookupInImportsAndUses( LookupConfig config, IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet& excludeFilter, - VisibilitySymbols::ShadowScope shadowScope) { + VisibilitySymbols::ShadowScope shadowScope, + std::unordered_set* foundInClauses, + std::unordered_set* ignoreClauses) { bool onlyInnermost = (config & LOOKUP_INNERMOST) != 0; bool skipPrivateVisibilities = (config & LOOKUP_SKIP_PRIVATE_VIS) != 0; bool onlyMethodsFields = (config & LOOKUP_ONLY_METHODS_FIELDS) != 0; @@ -619,6 +623,13 @@ bool LookupHelper::doLookupInImportsAndUses( if (is.shadowScopeLevel() != shadowScope) { continue; } + + // skip visibility clauses specified in ignoreClauses + if (ignoreClauses && ignoreClauses->count(is.visibilityClauseId())) { + continue; + } + + size_t firstResultThisClause = result.size(); UniqueString from = name; bool named = is.lookupName(name, from); if (named && is.kind() == VisibilitySymbols::CONTENTS_EXCEPT) { @@ -717,6 +728,10 @@ bool LookupHelper::doLookupInImportsAndUses( found = true; } } + + if (foundInClauses && found && firstResultThisClause < result.size()) { + foundInClauses->insert(is.visibilityClauseId()); + } } } @@ -1075,6 +1090,7 @@ bool LookupHelper::doLookupInScope(const Scope* scope, shadowedResults != nullptr; bool checkMoreForWarning = false; size_t firstResultForWarning = 0; + std::unordered_set foundInShadowScopeOneClauses; // gather non-shadow scope information // (declarations in this scope as well as public use / import) @@ -1095,15 +1111,18 @@ bool LookupHelper::doLookupInScope(const Scope* scope, bool gotLocalDecls = got; got |= doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, - VisibilitySymbols::REGULAR_SCOPE); + VisibilitySymbols::REGULAR_SCOPE, + /* foundInClauses */ nullptr, + /* ignoreClauses */ nullptr); if (got && !gotLocalDecls && canCheckMoreForWarning) { // if we only found it in a 'public use' etc, - // check the shadow scopes in addition, to potentially warn. + // check the other scopes in addition, to potentially warn. checkMoreForWarning = true; + onlyInnermost = false; firstResultForWarning = result.size(); } } - if (onlyInnermost && got && !checkMoreForWarning) return true; + if (onlyInnermost && got) return true; } // now check shadow scope 1 (only relevant for 'private use') @@ -1111,7 +1130,9 @@ bool LookupHelper::doLookupInScope(const Scope* scope, bool got = false; got |= doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, - VisibilitySymbols::SHADOW_SCOPE_ONE); + VisibilitySymbols::SHADOW_SCOPE_ONE, + &foundInShadowScopeOneClauses, + /* ignoreClauses */ nullptr); // treat the auto-used modules as if they were 'private use'd got |= doLookupInAutoModules(scope, name, @@ -1121,9 +1142,17 @@ bool LookupHelper::doLookupInScope(const Scope* scope, includeMethods); if (got && canCheckMoreForWarning && !checkMoreForWarning) { checkMoreForWarning = true; + onlyInnermost = false; firstResultForWarning = result.size(); } - if (onlyInnermost && got && !checkMoreForWarning) return true; + if (onlyInnermost && got) return true; + } + + std::unordered_set* ignoreClausesForShadowScope2 = nullptr; + if (checkMoreForWarning) { + // ignore 'use M' bringing in M and hiding the module name, + // for the purpose of the warning. + ignoreClausesForShadowScope2 = &foundInShadowScopeOneClauses; } // now check shadow scope 2 (only relevant for 'private use') @@ -1131,42 +1160,15 @@ bool LookupHelper::doLookupInScope(const Scope* scope, bool got = false; got = doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, - VisibilitySymbols::SHADOW_SCOPE_TWO); + VisibilitySymbols::SHADOW_SCOPE_TWO, + /* foundInClauses */ nullptr, + ignoreClausesForShadowScope2); if (got && canCheckMoreForWarning && !checkMoreForWarning) { checkMoreForWarning = true; + onlyInnermost = false; firstResultForWarning = result.size(); } - if (onlyInnermost && got && !checkMoreForWarning) return true; - } - - if (checkMoreForWarning) { - // we are going to return before considering other scopes, - // but we wish to warn if there is also a match in a toplevel module, - // so check that now. - if (checkToplevel) { - doLookupInToplevelModules(scope, name); - } - - if (firstResultForWarning < result.size()) { - // move results after firstResultForWarning to shadowedResults - // and similarly move traceResults - for (size_t i = firstResultForWarning; i < result.size(); i++) { - shadowedResults->push_back(std::move(result[i])); - if (trace && traceShadowedResults) { - traceShadowedResults->push_back(std::move((*traceResult)[i])); - } - } - - result.erase(result.begin() + firstResultForWarning, result.end()); - if (trace) { - traceResult->erase(traceResult->begin() + firstResultForWarning, - traceResult->end()); - } - } - - // either way, stop now that we have completed searching the - // additional scopes we wanted to check for the warning. - return true; + if (onlyInnermost && got) return true; } // If we are at a method scope, consider receiver scopes now @@ -1279,6 +1281,35 @@ bool LookupHelper::doLookupInScope(const Scope* scope, doLookupInExternBlocks(scope, name); } + if (checkMoreForWarning) { + if (firstResultForWarning < result.size()) { + std::unordered_set foundFirstIds; + + for (size_t i = 0; i < firstResultForWarning; i++) { + foundFirstIds.insert(result[i].firstId()); + } + + // move results after firstResultForWarning to shadowedResults + // and similarly move traceResults + for (size_t i = firstResultForWarning; i < result.size(); i++) { + auto pair = foundFirstIds.insert(result[i].firstId()); + if (pair.second) { + // if it's the first time finding it, add to shadowedResults + shadowedResults->push_back(std::move(result[i])); + if (trace && traceShadowedResults) { + traceShadowedResults->push_back(std::move((*traceResult)[i])); + } + } + } + + result.erase(result.begin() + firstResultForWarning, result.end()); + if (trace) { + traceResult->erase(traceResult->begin() + firstResultForWarning, + traceResult->end()); + } + } + } + if (trace) { // check that traceCurPath push/pop are balanced CHPL_ASSERT(traceCurPath->size() == traceCurPathSize); From 0033e28a65ce5d8551489c17574571b71475aa3a Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 22 Sep 2023 16:04:32 -0400 Subject: [PATCH 04/35] Add tests for warning --- Signed-off-by: Michael Ferguson --- .../unexpected-shadowing-warning/MM.chpl | 1 + .../unexpected-shadowing-warning/MM.notest | 0 .../hijacking-example.chpl | 25 +++++++++++++++++++ .../hijacking-example.good | 7 ++++++ .../no-warn-same-use-shadows.chpl | 10 ++++++++ .../no-warn-same-use-shadows.good | 1 + .../public-private-bring-samename.chpl | 16 ++++++++++++ .../public-private-bring-samename.good | 7 ++++++ .../submodule-in-used-vs-submodule.chpl | 17 +++++++++++++ .../submodule-in-used-vs-submodule.good | 10 ++++++++ .../submodule-in-used-vs-toplevel-1.chpl | 17 +++++++++++++ .../submodule-in-used-vs-toplevel-1.good | 7 ++++++ .../submodule-in-used-vs-toplevel-2.chpl | 17 +++++++++++++ .../submodule-in-used-vs-toplevel-2.good | 6 +++++ .../submodule-in-used-vs-toplevel-3.chpl | 17 +++++++++++++ .../submodule-in-used-vs-toplevel-3.good | 5 ++++ ...submodule-in-used-vs-toplevel-in-file.chpl | 12 +++++++++ ...submodule-in-used-vs-toplevel-in-file.good | 6 +++++ 18 files changed, 181 insertions(+) create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/MM.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/MM.notest create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good diff --git a/test/modules/shadowing/unexpected-shadowing-warning/MM.chpl b/test/modules/shadowing/unexpected-shadowing-warning/MM.chpl new file mode 100644 index 000000000000..72dca869bf61 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/MM.chpl @@ -0,0 +1 @@ +module MM { var x: real; } diff --git a/test/modules/shadowing/unexpected-shadowing-warning/MM.notest b/test/modules/shadowing/unexpected-shadowing-warning/MM.notest new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.chpl b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.chpl new file mode 100644 index 000000000000..b36d3fa3b59f --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.chpl @@ -0,0 +1,25 @@ +module M { + proc bar() { + writeln("Computing bar()"); + } + module N { + proc foo() { + writeln("Hijacked!"); + } + } +} + +module N { + proc foo() { + writeln("Computing foo()"); + } +} + +module Main { + proc main() { + use M; + use N; + foo(); // this now calls the hijacked version + bar(); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good new file mode 100644 index 000000000000..533e9788d542 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good @@ -0,0 +1,7 @@ +hijacking-example.chpl:19: In function 'main': +hijacking-example.chpl:21: warning: potentially surprising shadowing for 'N' +hijacking-example.chpl:20: note: it refers to a symbol found through the 'use' statement here +hijacking-example.chpl:5: note: leading to 'N' defined here +hijacking-example.chpl:12: note: but there is a shadowed symbol 'N' defined here +Hijacked! +Computing bar() diff --git a/test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.chpl b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.chpl new file mode 100644 index 000000000000..d034f5c49c61 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.chpl @@ -0,0 +1,10 @@ +module A { + var A: int; +} + +module Main { + use A; + proc main() { + writeln(A); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.good b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.good new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-same-use-shadows.good @@ -0,0 +1 @@ +0 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.chpl b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.chpl new file mode 100644 index 000000000000..f2ab7afcc058 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.chpl @@ -0,0 +1,16 @@ +module M { + var x: int = 1; +} + +module N { + var x: int = 2; +} + +module App { + public use M; + private use N; + + proc main() { + writeln(x); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good new file mode 100644 index 000000000000..cbf79ff01d62 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good @@ -0,0 +1,7 @@ +public-private-bring-samename.chpl:13: In function 'main': +public-private-bring-samename.chpl:14: warning: potentially surprising shadowing for 'x' +public-private-bring-samename.chpl:10: note: it refers to a symbol found through the 'use' statement here +public-private-bring-samename.chpl:2: note: leading to 'x' defined here +public-private-bring-samename.chpl:11: note: but there is a shadowed symbol found through the 'use' statement here +public-private-bring-samename.chpl:6: note: leading to 'x' defined here +1 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.chpl b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.chpl new file mode 100644 index 000000000000..e19ea30ad650 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.chpl @@ -0,0 +1,17 @@ +module Application { + module M { + module N { + var x = 100; + } + } + + module N { + var x = 42; + } + + proc main() { + use M; + use N only; + writeln(N.x); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good new file mode 100644 index 000000000000..d39195397574 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good @@ -0,0 +1,10 @@ +submodule-in-used-vs-submodule.chpl:12: In function 'main': +submodule-in-used-vs-submodule.chpl:14: warning: potentially surprising shadowing for 'N' +submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-submodule.chpl:3: note: leading to 'N' defined here +submodule-in-used-vs-submodule.chpl:8: note: but there is a shadowed symbol 'N' defined here +submodule-in-used-vs-submodule.chpl:15: warning: potentially surprising shadowing for 'N' +submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-submodule.chpl:3: note: leading to 'N' defined here +submodule-in-used-vs-submodule.chpl:8: note: but there is a shadowed symbol 'N' defined here +100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.chpl b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.chpl new file mode 100644 index 000000000000..edb77d95fee4 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.chpl @@ -0,0 +1,17 @@ +module M { + module N { + var x = 100; + } +} + +module N { + var x = 42; +} + +module Application { + use N only; + use M; + proc main() { + writeln(N.x); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good new file mode 100644 index 000000000000..20320dddeca6 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good @@ -0,0 +1,7 @@ +submodule-in-used-vs-toplevel-1.chpl:14: In function 'main': +submodule-in-used-vs-toplevel-1.chpl:15: warning: potentially surprising shadowing for 'N' +submodule-in-used-vs-toplevel-1.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-1.chpl:2: note: leading to 'N' defined here +submodule-in-used-vs-toplevel-1.chpl:12: note: but there is a shadowed symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-1.chpl:7: note: leading to 'N' defined here +100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.chpl b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.chpl new file mode 100644 index 000000000000..a4ea411efd9f --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.chpl @@ -0,0 +1,17 @@ +module M { + module N { + var x = 100; + } +} + +module N { + var x = 42; +} + +module Application { + use M; + use N only; + proc main() { + writeln(N.x); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good new file mode 100644 index 000000000000..52750a1fd634 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good @@ -0,0 +1,6 @@ +submodule-in-used-vs-toplevel-2.chpl:11: In module 'Application': +submodule-in-used-vs-toplevel-2.chpl:13: warning: potentially surprising shadowing for 'N' +submodule-in-used-vs-toplevel-2.chpl:12: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-2.chpl:2: note: leading to 'N' defined here +submodule-in-used-vs-toplevel-2.chpl:7: note: but there is a shadowed symbol 'N' defined here +100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.chpl b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.chpl new file mode 100644 index 000000000000..0c265c2ef182 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.chpl @@ -0,0 +1,17 @@ +module M { + module N { + var x: int; + } +} + +module N { + var x: real; +} + +module Main { + proc main() { + use M; + use N; + x; + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good new file mode 100644 index 000000000000..47e74b54b44f --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good @@ -0,0 +1,5 @@ +submodule-in-used-vs-toplevel-3.chpl:12: In function 'main': +submodule-in-used-vs-toplevel-3.chpl:14: warning: potentially surprising shadowing for 'N' +submodule-in-used-vs-toplevel-3.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-3.chpl:2: note: leading to 'N' defined here +submodule-in-used-vs-toplevel-3.chpl:7: note: but there is a shadowed symbol 'N' defined here diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.chpl b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.chpl new file mode 100644 index 000000000000..69612db6de7d --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.chpl @@ -0,0 +1,12 @@ +module N { + module MM { var x: int; } +} + +module Main { + + proc main() { + use N; + use MM; + writeln(x); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good new file mode 100644 index 000000000000..b0f2a26a7397 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good @@ -0,0 +1,6 @@ +submodule-in-used-vs-toplevel-in-file.chpl:7: In function 'main': +submodule-in-used-vs-toplevel-in-file.chpl:9: warning: potentially surprising shadowing for 'MM' +submodule-in-used-vs-toplevel-in-file.chpl:8: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-in-file.chpl:2: note: leading to 'MM' defined here +MM.chpl:1: note: but there is a shadowed symbol 'MM' defined here +0 From 753345b43aec865599ab8d1de3565ea2b49aff77 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 22 Sep 2023 16:12:22 -0400 Subject: [PATCH 05/35] Add more tests --- Signed-off-by: Michael Ferguson --- .../import-vs-outer.chpl | 12 ++++++++++++ .../import-vs-outer.good | 1 + .../private-use-vs-outer.chpl | 12 ++++++++++++ .../private-use-vs-outer.good | 6 ++++++ .../public-use-vs-outer.chpl | 12 ++++++++++++ .../public-use-vs-outer.good | 6 ++++++ 6 files changed, 49 insertions(+) create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good diff --git a/test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.chpl b/test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.chpl new file mode 100644 index 000000000000..02cd43693269 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.chpl @@ -0,0 +1,12 @@ +module M { + var x: int = 42; +} + +module N { + var x: real; + proc main() { + import M.x; + writeln(x); + } +} + diff --git a/test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.good new file mode 100644 index 000000000000..d81cc0710eb6 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/import-vs-outer.good @@ -0,0 +1 @@ +42 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.chpl b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.chpl new file mode 100644 index 000000000000..f14d6f873711 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.chpl @@ -0,0 +1,12 @@ +module M { + var x: int = 42; +} + +module N { + var x: real; + proc main() { + private use M; + writeln(x); + } +} + diff --git a/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good new file mode 100644 index 000000000000..0982932edd02 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good @@ -0,0 +1,6 @@ +private-use-vs-outer.chpl:7: In function 'main': +private-use-vs-outer.chpl:9: warning: potentially surprising shadowing for 'x' +private-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' statement here +private-use-vs-outer.chpl:2: note: leading to 'x' defined here +private-use-vs-outer.chpl:6: note: but there is a shadowed symbol 'x' defined here +42 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.chpl b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.chpl new file mode 100644 index 000000000000..9b7e0bf8cc4c --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.chpl @@ -0,0 +1,12 @@ +module M { + var x: int = 42; +} + +module N { + var x: real; + proc main() { + public use M; + writeln(x); + } +} + diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good new file mode 100644 index 000000000000..cd9ace7058c9 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good @@ -0,0 +1,6 @@ +public-use-vs-outer.chpl:7: In function 'main': +public-use-vs-outer.chpl:9: warning: potentially surprising shadowing for 'x' +public-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' statement here +public-use-vs-outer.chpl:2: note: leading to 'x' defined here +public-use-vs-outer.chpl:6: note: but there is a shadowed symbol 'x' defined here +42 From 293b41c616ed37600d8a0a8dd20b943ff369420c Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 22 Sep 2023 16:29:45 -0400 Subject: [PATCH 06/35] Don't warn for import in shadow scope 0 --- Signed-off-by: Michael Ferguson --- frontend/lib/resolution/scope-queries.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 39b2e479ed0b..82decb0f742c 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -522,6 +522,7 @@ struct LookupHelper { IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet& excludeFilter, VisibilitySymbols::ShadowScope shadowScope, + bool* foundInAllContents, std::unordered_set* foundInClauses, std::unordered_set* ignoreClauses); @@ -593,6 +594,7 @@ bool LookupHelper::doLookupInImportsAndUses( IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet& excludeFilter, VisibilitySymbols::ShadowScope shadowScope, + bool* foundInAllContents, std::unordered_set* foundInClauses, std::unordered_set* ignoreClauses) { bool onlyInnermost = (config & LOOKUP_INNERMOST) != 0; @@ -685,7 +687,16 @@ bool LookupHelper::doLookupInImportsAndUses( traceCurPath->push_back(std::move(elt)); } - found |= doLookupInScope(symScope, {}, nameToLookUp, newConfig); + bool foundHere = doLookupInScope(symScope, {}, nameToLookUp, newConfig); + found |= foundHere; + // note if we found it from the contents in a bulk + // operation like 'use M' + if (is.kind() == VisibilitySymbols::ALL_CONTENTS || + is.kind() == VisibilitySymbols::CONTENTS_EXCEPT) { + if (foundHere && foundInAllContents) { + *foundInAllContents = true; + } + } if (trace) { traceCurPath->pop_back(); @@ -1109,12 +1120,14 @@ bool LookupHelper::doLookupInScope(const Scope* scope, } if (checkUseImport) { bool gotLocalDecls = got; + bool foundInAll = false; got |= doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, VisibilitySymbols::REGULAR_SCOPE, + &foundInAll, /* foundInClauses */ nullptr, /* ignoreClauses */ nullptr); - if (got && !gotLocalDecls && canCheckMoreForWarning) { + if (got && !gotLocalDecls && canCheckMoreForWarning && foundInAll) { // if we only found it in a 'public use' etc, // check the other scopes in addition, to potentially warn. checkMoreForWarning = true; @@ -1131,6 +1144,7 @@ bool LookupHelper::doLookupInScope(const Scope* scope, got |= doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, VisibilitySymbols::SHADOW_SCOPE_ONE, + /* foundInAllContents */ nullptr, &foundInShadowScopeOneClauses, /* ignoreClauses */ nullptr); @@ -1161,6 +1175,7 @@ bool LookupHelper::doLookupInScope(const Scope* scope, got = doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, VisibilitySymbols::SHADOW_SCOPE_TWO, + /* foundInAllContents */ nullptr, /* foundInClauses */ nullptr, ignoreClausesForShadowScope2); if (got && canCheckMoreForWarning && !checkMoreForWarning) { From e98d54551ee3391cadc9535c28893e84713a0b7e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 10:49:07 -0400 Subject: [PATCH 07/35] Move symbolic link creation to before running tests So that if a test fails, the symbolic link still exists --- Signed-off-by: Michael Ferguson --- compiler/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/Makefile b/compiler/Makefile index 1a740c37aa5d..72f36659ed50 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -167,10 +167,11 @@ frontend: FORCE $(CHPL_CONFIG_CHECK) $(COMPILER_BUILD) test-frontend: FORCE $(CHPL_CONFIG_CHECK) $(COMPILER_BUILD) @echo "Making and running the frontend tests..." @cd $(COMPILER_BUILD) && $(CMAKE) $(CHPL_MAKE_HOME) $(CMAKE_FLAGS_NO_NDEBUG) && $(MAKE) tests - JOBSFLAG=`echo "$$MAKEFLAGS" | sed -n 's/.*\(-j\|--jobs=\) *\([0-9][0-9]*\).*/-j\2/p'` ; \ - cd $(COMPILER_BUILD)/frontend/test && ctest $$JOBSFLAG . ; @echo "Making symbolic link to frontend tests in build/frontend-test" @cd ../build && rm -f frontend-test && ln -s $(COMPILER_BUILD)/frontend/test frontend-test + JOBSFLAG=`echo "$$MAKEFLAGS" | sed -n 's/.*\(-j\|--jobs=\) *\([0-9][0-9]*\).*/-j\2/p'` ; \ + cd $(COMPILER_BUILD)/frontend/test && ctest $$JOBSFLAG . ; + @echo "frontend tests are available in build/frontend-test" COPY_IF_DIFFERENT = $(CHPL_MAKE_PYTHON) $(CHPL_MAKE_HOME)/util/config/update-if-different --quiet --copy From 9200fe6b109700ee9ea089b962252bc376c454f4 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 10:49:49 -0400 Subject: [PATCH 08/35] With c_string deprecation, primitive type is chpl_c_string Resolves a spurious warning for arrays/literals/cStringLiteral --- Signed-off-by: Michael Ferguson --- frontend/lib/types/Type.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/lib/types/Type.cpp b/frontend/lib/types/Type.cpp index ea6bc268bd37..2f66af29e653 100644 --- a/frontend/lib/types/Type.cpp +++ b/frontend/lib/types/Type.cpp @@ -99,7 +99,7 @@ void Type::gatherBuiltins(Context* context, gatherType(context, map, "_any", AnyType::get(context)); gatherType(context, map, "_nilType", NilType::get(context)); gatherType(context, map, "_unknown", UnknownType::get(context)); - gatherType(context, map, "c_string", CStringType::get(context)); + gatherType(context, map, "chpl_c_string", CStringType::get(context)); gatherType(context, map, "nothing", NothingType::get(context)); gatherType(context, map, "void", VoidType::get(context)); From 3061f81f5e8d2ba886b434ded0d64dcd575a2b14 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 10:51:31 -0400 Subject: [PATCH 09/35] Adjust a test in testScopeResolve.cpp to expect the new warning --- Signed-off-by: Michael Ferguson --- frontend/test/resolution/testScopeResolve.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/test/resolution/testScopeResolve.cpp b/frontend/test/resolution/testScopeResolve.cpp index 20ca8d4d7b2f..293fcb6be6ff 100644 --- a/frontend/test/resolution/testScopeResolve.cpp +++ b/frontend/test/resolution/testScopeResolve.cpp @@ -710,7 +710,13 @@ static void test18() { const ResolvedExpression& reY = scopeResolveIt(context, x->initExpression()); assert(reY.toId().str() == "M@1"); + + // expect a warning for this code + assert(guard.numErrors() == 1); + assert(guard.error(0)->kind() == ErrorBase::WARNING); + guard.realizeErrors(); } + // check that 'private use M' puts M in a further shadow scope from contents static void test19() { printf("test19\n"); From 2073b076ca619be960cc7f9faa26d38112cc896d Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 10:51:55 -0400 Subject: [PATCH 10/35] Update modules.good At this point in the primer, it is showing how the conflict will be resolved, so the warning is appropriate. --- Signed-off-by: Michael Ferguson --- test/release/examples/primers/modules.good | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/release/examples/primers/modules.good b/test/release/examples/primers/modules.good index e6b1236f8481..7b620c646892 100644 --- a/test/release/examples/primers/modules.good +++ b/test/release/examples/primers/modules.good @@ -1,3 +1,8 @@ +modules.chpl:126: In function 'main': +modules.chpl:306: warning: potentially surprising shadowing for 'bar' +modules.chpl:305: note: it refers to a symbol found through the 'use' statement here +modules.chpl:37: note: leading to 'bar' defined here +modules.chpl:302: note: but there is a shadowed symbol 'bar' defined here Start of reverse file-order output This function is accessible! This function is accessible! From a2e7fcde99c34e82736c86d03331aa01095fadf5 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 11:25:56 -0400 Subject: [PATCH 11/35] Adjust error message wording for builtin modules --- Signed-off-by: Michael Ferguson --- .../lib/resolution/resolution-error-classes-list.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/frontend/lib/resolution/resolution-error-classes-list.cpp b/frontend/lib/resolution/resolution-error-classes-list.cpp index 141a9ba59a7e..0e7218655039 100644 --- a/frontend/lib/resolution/resolution-error-classes-list.cpp +++ b/frontend/lib/resolution/resolution-error-classes-list.cpp @@ -109,13 +109,7 @@ static void describeSymbolTrace(ErrorWriterBase& wr, if (start==0 && needsIntroText) { msg = intro; } - if (from != name) { - msg += "'" + from.str() + "'"; - } else { - msg += "it"; - } - wr.note(errId, msg, - " was provided by the automatically-included modules."); + wr.note(errId, msg, "in the automatically-included modules."); encounteredAutoModule = true; needsIntroText = false; break; @@ -775,7 +769,7 @@ void ErrorPotentiallySurprisingShadowing::write(ErrorWriterBase& wr) const { const char* intro = "it refers to a symbol found "; bool encounteredAutoModule = false; UniqueString from; - bool needsIntroText = false; + bool needsIntroText = true; ID firstId = result[0].firstId(); From b07c5c7b18dca11bf39a66f5f91a0a33baaeb7c5 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 11:53:23 -0400 Subject: [PATCH 12/35] Ignore root scope for warning Because the root scope often defines names also available in the auto-used modules. --- Signed-off-by: Michael Ferguson --- frontend/lib/resolution/scope-queries.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 82decb0f742c..4d1e17b5db6e 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -1266,7 +1266,11 @@ bool LookupHelper::doLookupInScope(const Scope* scope, if (cur->parentScope() == nullptr) rootScope = cur; } - if (rootScope != nullptr) { + // Ignore the root scope checking if we already found a match + // and we are looking for other matches for warning purposes. + // Otherwise, we will get errors relating to finding e.g. Error + // both in the standard library and in the built-in types. + if (rootScope != nullptr && !checkMoreForWarning) { if (trace) { VisibilityTraceElt elt; elt.rootScope = true; From 96b5bf19861095a6b715c4d097a86a146cf710fd Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 11:54:55 -0400 Subject: [PATCH 13/35] Replace HiddenFormal warning with the new one --- Signed-off-by: Michael Ferguson --- .../resolution-error-classes-list.h | 1 - .../resolution-error-classes-list.cpp | 51 +------- frontend/lib/resolution/scope-queries.cpp | 109 ------------------ .../use-shadows-formal1.1-0.good | 6 +- .../use-shadows-formal1.2-0.good | 18 +-- .../use-shadows-formal2.1.good | 6 +- .../use-shadows-formal2.2.good | 18 +-- 7 files changed, 32 insertions(+), 177 deletions(-) diff --git a/frontend/include/chpl/resolution/resolution-error-classes-list.h b/frontend/include/chpl/resolution/resolution-error-classes-list.h index c26c714017bc..30e05b4d8070 100644 --- a/frontend/include/chpl/resolution/resolution-error-classes-list.h +++ b/frontend/include/chpl/resolution/resolution-error-classes-list.h @@ -40,7 +40,6 @@ ERROR_CLASS(AsWithUseExcept, const uast::Use*, const uast::As*) WARNING_CLASS(Deprecation, std::string, const uast::AstNode*, const uast::NamedDecl*) ERROR_CLASS(DotExprInUseImport, const uast::VisibilityClause*, const uast::VisibilityClause::LimitationKind, const uast::Dot*) ERROR_CLASS(ExternCCompilation, ID, std::vector>) -WARNING_CLASS(HiddenFormal, const uast::Formal*, resolution::BorrowedIdsWithName, resolution::ResultVisibilityTrace) ERROR_CLASS(IfVarNonClassType, const uast::Conditional*, types::QualifiedType) WARNING_CLASS(ImplicitFileModule, const uast::AstNode*, const uast::Module*, const uast::Module*) ERROR_CLASS(IncompatibleIfBranches, const uast::Conditional*, types::QualifiedType, types::QualifiedType) diff --git a/frontend/lib/resolution/resolution-error-classes-list.cpp b/frontend/lib/resolution/resolution-error-classes-list.cpp index 0e7218655039..0a31cc49f079 100644 --- a/frontend/lib/resolution/resolution-error-classes-list.cpp +++ b/frontend/lib/resolution/resolution-error-classes-list.cpp @@ -299,53 +299,6 @@ void ErrorExternCCompilation::write(ErrorWriterBase& wr) const { } } -void ErrorHiddenFormal::write(ErrorWriterBase& wr) const { - auto formal = std::get(info); - const auto& match = std::get(info); - const auto& trace = std::get(info); - CHPL_ASSERT(formal && !trace.visibleThrough.empty()); - - // find the first visibility clause ID - ID firstVisibilityClauseId; - resolution::VisibilityStmtKind firstUseOrImport = resolution::VIS_USE; - - int start = 0; - - int i = 0; - for (const auto& elt : trace.visibleThrough) { - if (elt.fromUseImport) { - firstVisibilityClauseId = elt.visibilityClauseId; - firstUseOrImport = elt.visibilityStmtKind; - start = i+1; // skip this one in describeSymbolTrace - break; - } - i++; - } - - wr.heading(kind_, type_, firstVisibilityClauseId, - "module-level symbol is hiding function argument '", - formal->name(), "'"); - - wr.message("The formal argument:"); - wr.code(formal, { formal }); - wr.message("is shadowed by a symbol provided by the following '", - firstUseOrImport, "' statement:"); - wr.code(firstVisibilityClauseId, { firstVisibilityClauseId }); - - // print where it came from - bool encounteredAutoModule = false; - UniqueString from; - bool needsIntroText = true; - describeSymbolTrace(wr, formal->id(), formal->name(), trace, start, "", - encounteredAutoModule, from, needsIntroText); - - if (!encounteredAutoModule) { - ID firstId = match.firstId(); - wr.note(locationOnly(firstId), "found '", from, "' defined here:"); - wr.code(firstId, { firstId }); - } -} - void ErrorIfVarNonClassType::write(ErrorWriterBase& wr) const { auto cond = std::get(info); auto qtVar = std::get(info); @@ -784,14 +737,14 @@ void ErrorPotentiallySurprisingShadowing::write(ErrorWriterBase& wr) const { } wr.code(firstId, { firstId }); - const char* intro2 = "but there is a shadowed symbol found "; + const char* intro2 = "but, there is a shadowed symbol found "; describeSymbolTrace(wr, id, name, traceShadowed[0], /* start */ 0, intro2, encounteredAutoModule, from, needsIntroText); ID otherId = shadowed[0].firstId(); if (needsIntroText) { - wr.note(locationOnly(otherId), "but there is a shadowed symbol '", from, "' defined here:"); + wr.note(locationOnly(otherId), "but, there is a shadowed symbol '", from, "' defined here:"); } else { wr.note(locationOnly(otherId), "leading to '", from, "' defined here:"); } diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 4d1e17b5db6e..c3009f4edcbf 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -2417,100 +2417,6 @@ const owned& resolveVisibilityStmtsQuery( return QUERY_END(result); } -static void -doWarnHiddenFormal(Context* context, - const Scope* functionScope, - UniqueString formalName, - const BorrowedIdsWithName& match, - const ResultVisibilityTrace& traceResult) { - // find the Formal* - const Formal* formal = nullptr; - std::vector ids; - IdAndFlags::Flags filterFlags = 0; - IdAndFlags::FlagSet excludeFlagSet; - functionScope->lookupInScope(formalName, ids, filterFlags, excludeFlagSet); - for (const auto& b : ids) { - for (const auto& id : b) { - auto formalAst = parsing::idToAst(context, id); - if (formalAst != nullptr) { - formal = formalAst->toFormal(); - break; - } - } - } - - if (formal) { - CHPL_REPORT(context, HiddenFormal, formal, match, traceResult); - } -} - -static const bool& warnHiddenFormalsQuery(Context* context, - const ResolvedVisibilityScope* rs, - const Scope* functionScope) { - QUERY_BEGIN(warnHiddenFormalsQuery, context, rs, functionScope); - - bool result = false; - - // warn if a function formal name conflicts with something - // brought in by use/import. - - std::set formalNames = functionScope->gatherNames(); - - CheckedScopes checkedScopes; - std::vector matches; - - for (auto name : formalNames) { - LookupConfig config = LOOKUP_IMPORT_AND_USE; - bool foundExternBlock = false; // ignored - bool got = false; - - auto helper = LookupHelper(context, rs, checkedScopes, matches, - foundExternBlock, - /* traceCurPath */ nullptr, - /* traceResult */ nullptr, - /* shadowedResults */ nullptr, - /* traceShadowedResults */ nullptr); - - - got = helper.doLookupInScope(rs->scope(), {}, name, config); - - // Check that there is a match that isn't a method/field - // to skip the warning for collisions with secondary methods. - bool onlyMethodsFields = true; - size_t errIdx = 0; - if (got) { - size_t i = 0; - for (const auto& b : matches) { - if (!b.containsOnlyMethodsOrFields()) { - errIdx = i; - onlyMethodsFields = false; - break; - } - i++; - } - } - - if (got && !onlyMethodsFields) { - // repeat the lookup with tracing enabled - matches.clear(); - checkedScopes.clear(); - std::vector traceCurPath; - std::vector traceResult; - helper.traceCurPath = &traceCurPath; - helper.traceResult = &traceResult; - - helper.doLookupInScope(rs->scope(), {}, name, config); - - CHPL_ASSERT(errIdx < traceResult.size()); - doWarnHiddenFormal(context, functionScope, name, - matches[errIdx], traceResult[errIdx]); - result = true; - } - } - - return QUERY_END(result); -} - const ResolvedVisibilityScope* resolveVisibilityStmts(Context* context, const Scope* scope) { if (!scope->containsUseImport()) { @@ -2529,21 +2435,6 @@ resolveVisibilityStmts(Context* context, const Scope* scope) { resolveVisibilityStmtsQuery(context, scope); const ResolvedVisibilityScope* r = o.get(); - // If it's inside a function scope (which is rare for use/import), - // warn for hidden formals - const Scope* functionScope = nullptr; - for (const Scope* s = scope->parentScope(); - s != nullptr; - s = s->parentScope()) { - if (asttags::isFunction(s->tag())) { - functionScope = s; - break; - } - } - if (functionScope != nullptr) { - warnHiddenFormalsQuery(context, r, functionScope); - } - return r; } diff --git a/test/errors/scope-resolution/use-shadows-formal1.1-0.good b/test/errors/scope-resolution/use-shadows-formal1.1-0.good index 82273314b412..a931d8bcdff7 100644 --- a/test/errors/scope-resolution/use-shadows-formal1.1-0.good +++ b/test/errors/scope-resolution/use-shadows-formal1.1-0.good @@ -1,5 +1,7 @@ use-shadows-formal1.chpl:13: In function 'foo': -use-shadows-formal1.chpl:14: warning: module-level symbol is hiding function argument 'a' +use-shadows-formal1.chpl:15: warning: potentially surprising shadowing for 'a' +use-shadows-formal1.chpl:14: note: it refers to a symbol found through the 'use' statement here use-shadows-formal1.chpl:6: note: and then through the 'use' statement here -use-shadows-formal1.chpl:2: note: found 'b' defined here +use-shadows-formal1.chpl:2: note: leading to 'b' defined here +use-shadows-formal1.chpl:13: note: but, there is a shadowed symbol 'a' defined here 0 diff --git a/test/errors/scope-resolution/use-shadows-formal1.2-0.good b/test/errors/scope-resolution/use-shadows-formal1.2-0.good index 095379c06ff4..73a014cc79b3 100644 --- a/test/errors/scope-resolution/use-shadows-formal1.2-0.good +++ b/test/errors/scope-resolution/use-shadows-formal1.2-0.good @@ -1,11 +1,10 @@ -─── warning in use-shadows-formal1.chpl:14 [HiddenFormal] ─── - Module-level symbol is hiding function argument 'a' - The formal argument: +─── warning in use-shadows-formal1.chpl:15 [PotentiallySurprisingShadowing] ─── + Potentially surprising shadowing for 'a' | - 13 | proc foo(a: real) { - | ⎺⎺⎺⎺⎺⎺⎺⎺ + 15 | writeln(a); + | ⎺ | - is shadowed by a symbol provided by the following 'use' statement: + It refers to a symbol found through the 'use' statement here: | 14 | use M1; | ⎺⎺ @@ -15,10 +14,15 @@ 6 | public use M0 only b as a; | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ | - Found 'b' defined here: + Leading to 'b' defined here: | 2 | var b: int; | ⎺⎺⎺⎺⎺⎺⎺ | + But, there is a shadowed symbol 'a' defined here: + | + 13 | proc foo(a: real) { + | ⎺⎺⎺⎺⎺⎺⎺⎺ + | 0 diff --git a/test/errors/scope-resolution/use-shadows-formal2.1.good b/test/errors/scope-resolution/use-shadows-formal2.1.good index 7449c228c2c7..8f6f3468c325 100644 --- a/test/errors/scope-resolution/use-shadows-formal2.1.good +++ b/test/errors/scope-resolution/use-shadows-formal2.1.good @@ -2,6 +2,8 @@ use-shadows-formal2.chpl:1: In module 'M0': use-shadows-formal2.chpl:2: error: 'b' has multiple definitions use-shadows-formal2.chpl:3: note: redefined here use-shadows-formal2.chpl:14: In function 'foo': -use-shadows-formal2.chpl:15: warning: module-level symbol is hiding function argument 'a' +use-shadows-formal2.chpl:16: warning: potentially surprising shadowing for 'a' +use-shadows-formal2.chpl:15: note: it refers to a symbol found through the 'use' statement here use-shadows-formal2.chpl:7: note: and then through the 'use' statement here -use-shadows-formal2.chpl:2: note: found 'b' defined here +use-shadows-formal2.chpl:2: note: leading to 'b' defined here +use-shadows-formal2.chpl:14: note: but, there is a shadowed symbol 'a' defined here diff --git a/test/errors/scope-resolution/use-shadows-formal2.2.good b/test/errors/scope-resolution/use-shadows-formal2.2.good index 13f3d9e19789..d2d415596140 100644 --- a/test/errors/scope-resolution/use-shadows-formal2.2.good +++ b/test/errors/scope-resolution/use-shadows-formal2.2.good @@ -11,14 +11,13 @@ | ⎺⎺⎺⎺⎺⎺⎺⎺ | -─── warning in use-shadows-formal2.chpl:15 [HiddenFormal] ─── - Module-level symbol is hiding function argument 'a' - The formal argument: +─── warning in use-shadows-formal2.chpl:16 [PotentiallySurprisingShadowing] ─── + Potentially surprising shadowing for 'a' | - 14 | proc foo(a: real) { - | ⎺⎺⎺⎺⎺⎺⎺⎺ + 16 | writeln(a); + | ⎺ | - is shadowed by a symbol provided by the following 'use' statement: + It refers to a symbol found through the 'use' statement here: | 15 | use M1; | ⎺⎺ @@ -28,9 +27,14 @@ 7 | public use M0 only b as a; | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ | - Found 'b' defined here: + Leading to 'b' defined here: | 2 | var b: int; | ⎺⎺⎺⎺⎺⎺⎺ | + But, there is a shadowed symbol 'a' defined here: + | + 14 | proc foo(a: real) { + | ⎺⎺⎺⎺⎺⎺⎺⎺ + | From ed01b01592293592d6742368f1d0e1b9ae3d943e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 12:08:44 -0400 Subject: [PATCH 14/35] Ignore extern block matches with the new warning For extern/ferguson/externblock/multi-module Justification: extern block matches that refer to the same C symbol are not a problem. --- Signed-off-by: Michael Ferguson --- frontend/lib/resolution/scope-queries.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index c3009f4edcbf..8d54c77900e4 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -1266,7 +1266,7 @@ bool LookupHelper::doLookupInScope(const Scope* scope, if (cur->parentScope() == nullptr) rootScope = cur; } - // Ignore the root scope checking if we already found a match + // Ignore checking the root module if we already found a match // and we are looking for other matches for warning purposes. // Otherwise, we will get errors relating to finding e.g. Error // both in the standard library and in the built-in types. @@ -1292,10 +1292,12 @@ bool LookupHelper::doLookupInScope(const Scope* scope, if (onlyInnermost && got) return true; } - // if LOOKUP_EXTERN_BLOCKS is set, and this scope has an extern block, + // If LOOKUP_EXTERN_BLOCKS is set, and this scope has an extern block, // and the name matches something in the extern block, - // return the extern block ID - if (checkExternBlocks && scope->containsExternBlock()) { + // return IDs of the matches within the extern block. + // Skip this checking for the warning. + if (checkExternBlocks && scope->containsExternBlock() && + !checkMoreForWarning) { foundExternBlock = true; doLookupInExternBlocks(scope, name); } From c6456d9012a48436a3c3f759c47f42a5d8e9e4e8 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 12:16:08 -0400 Subject: [PATCH 15/35] Un-future DuplicateConfigVars the new warning meets the original feature request --- Signed-off-by: Michael Ferguson --- .../DuplicateConfigVars.bad | 4 ---- .../DuplicateConfigVars.future | 10 --------- .../DuplicateConfigVars.good | 22 ++++++++++++++++++- 3 files changed, 21 insertions(+), 15 deletions(-) delete mode 100644 test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.bad delete mode 100644 test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.future diff --git a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.bad b/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.bad deleted file mode 100644 index 14e298ae8333..000000000000 --- a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.bad +++ /dev/null @@ -1,4 +0,0 @@ -Generated points: -7.8259e-06 0.131538 0.755605 0.45865 0.532767 0.218959 0.0470446 0.678865 0.679296 0.934693 -Number of points: 5 -Estimate of pi: 2.4 diff --git a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.future b/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.future deleted file mode 100644 index 23be5ca82e7a..000000000000 --- a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.future +++ /dev/null @@ -1,10 +0,0 @@ -semantic: warning for module use shadowing variable in outer scope - -really? Does Java or C# give a warning? - -feature request: compiler should warn about shadowing variables via use statement -If two modules define the same symbol, and both are in scope at the point -at which this symbol is used, the compiler should complain instead of -silently using the one introduced at the innermost scope (through a use -statement). In this test case, both seed and arraySize are defined -in both source files. diff --git a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good b/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good index daec01904f2f..8241d7ae3c73 100644 --- a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good +++ b/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good @@ -1,4 +1,24 @@ -DuplicateConfigVars.chpl:5: warning: imported symbol 'RandomNumber.arraySize' shadows symbol at outer scope +DuplicateConfigVars.chpl:4: In function 'main': +DuplicateConfigVars.chpl:6: warning: potentially surprising shadowing for 'arraySize' +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +RandomNumber.chpl:18: note: leading to 'arraySize' defined here +DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here +DuplicateConfigVars.chpl:9: warning: potentially surprising shadowing for 'arraySize' +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +RandomNumber.chpl:18: note: leading to 'arraySize' defined here +DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here +DuplicateConfigVars.chpl:12: warning: potentially surprising shadowing for 'arraySize' +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +RandomNumber.chpl:18: note: leading to 'arraySize' defined here +DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here +DuplicateConfigVars.chpl:16: warning: potentially surprising shadowing for 'arraySize' +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +RandomNumber.chpl:18: note: leading to 'arraySize' defined here +DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here +DuplicateConfigVars.chpl:19: warning: potentially surprising shadowing for 'arraySize' +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +RandomNumber.chpl:18: note: leading to 'arraySize' defined here +DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here Generated points: 7.8259e-06 0.131538 0.755605 0.45865 0.532767 0.218959 0.0470446 0.678865 0.679296 0.934693 Number of points: 5 From ef8dcf17d8b25a38474bc6b6700bbf4316affcf3 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 13:05:16 -0400 Subject: [PATCH 16/35] Avoid warning by renaming module Heap -> heap * globals.chpl defines class Heap * there is also a standard module Heap --- Signed-off-by: Michael Ferguson --- test/studies/dijkstra/BC_dijkstra.chpl | 2 +- test/studies/dijkstra/heap.chpl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/studies/dijkstra/BC_dijkstra.chpl b/test/studies/dijkstra/BC_dijkstra.chpl index c8267fa108bb..5def7d97e30a 100644 --- a/test/studies/dijkstra/BC_dijkstra.chpl +++ b/test/studies/dijkstra/BC_dijkstra.chpl @@ -1,6 +1,6 @@ module BC_dijkstra { - use Heap, NodesEdges; + use heap, NodesEdges; proc dijkstra(S: int, nEdges: int, nNodes: int, Edges, Nodes) { // Initialize stack diff --git a/test/studies/dijkstra/heap.chpl b/test/studies/dijkstra/heap.chpl index 722c1c7ac5e6..f290e0deb98a 100644 --- a/test/studies/dijkstra/heap.chpl +++ b/test/studies/dijkstra/heap.chpl @@ -1,5 +1,5 @@ -module Heap { +module heap { use NodesEdges; @@ -94,4 +94,4 @@ module Heap { HeapUp(size, heap, records); } -} \ No newline at end of file +} From e9d02a51202bccc9a8bb66495b328d8564e54a13 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 13:19:48 -0400 Subject: [PATCH 17/35] Update expected output for tests where the warning is reasonable --- Signed-off-by: Michael Ferguson --- test/deprecated-keyword/handleEnum.good | 8 ++++++++ test/modules/deitz/test_module_class_conflict2.good | 5 +++++ test/modules/deitz/test_module_use4.good | 5 +++++ test/modules/diten/moduleShadowFormal.good | 6 ++++-- test/modules/diten/test_use_chain_resolution.good | 7 +++++++ test/modules/diten/test_use_chain_resolution2.good | 6 ++++++ test/modules/noakes/mod-init-fails.good | 10 ++++++++++ test/modules/noakes/mod-init-works.good | 5 +++++ test/modules/shadowing/issue-19167-0.good | 5 +++++ test/modules/use/topLevel/modNameVsSecondUse.good | 6 ++++++ test/modules/use/topLevel/subVsTop.good | 6 ++++++ test/modules/use/topLevel/subVsTop1a.good | 9 +++++++++ test/modules/use/topLevel/subVsTop2.good | 6 ++++++ test/modules/use/topLevel/subVsTop2a.good | 9 +++++++++ test/release/examples/primers/modules.good | 2 +- test/types/enum/lydia/use/exceptList.good | 5 +++++ test/types/enum/lydia/use/onlyList.good | 5 +++++ test/types/enum/lydia/use/shadowsOuter.good | 9 +++++++++ test/types/enum/lydia/use/useMultiple.good | 6 ++++++ test/visibility/except/chainNoBlockLaterUse.good | 6 ++++++ test/visibility/import/submoduleCloser.bad | 4 ++++ .../innerModuleSharesName-topLevel-useInDiffScope.good | 4 ++++ test/visibility/prefer-explicit-use.good | 6 ++++++ test/visibility/rename/causesShadow.good | 5 +++++ .../renameUsedMod/renameSameNameAsInOtherMod.good | 5 +++++ .../renameUsedMod/renameSameNameAsInOtherMod2.good | 6 ++++++ .../rename/renameUsedMod/renameSameNameConflict3.good | 5 +++++ 27 files changed, 158 insertions(+), 3 deletions(-) diff --git a/test/deprecated-keyword/handleEnum.good b/test/deprecated-keyword/handleEnum.good index 83e7df756505..e914db08e912 100644 --- a/test/deprecated-keyword/handleEnum.good +++ b/test/deprecated-keyword/handleEnum.good @@ -3,6 +3,14 @@ handleEnum.chpl:6: warning: Enum e is deprecated, use enum f handleEnum.chpl:7: warning: Enum e is deprecated, use enum f handleEnum.chpl:8: warning: Enum e is deprecated, use enum f handleEnum.chpl:12: warning: Enum e is deprecated, use enum f +handleEnum.chpl:14: warning: potentially surprising shadowing for 'a' +handleEnum.chpl:12: note: it refers to a symbol found through the 'use' statement here +handleEnum.chpl:2: note: leading to 'a' defined here +handleEnum.chpl:6: note: but, there is a shadowed symbol 'a' defined here +handleEnum.chpl:16: warning: potentially surprising shadowing for 'c' +handleEnum.chpl:12: note: it refers to a symbol found through the 'use' statement here +handleEnum.chpl:2: note: leading to 'c' defined here +handleEnum.chpl:8: note: but, there is a shadowed symbol 'c' defined here b c a diff --git a/test/modules/deitz/test_module_class_conflict2.good b/test/modules/deitz/test_module_class_conflict2.good index 3f99f883a20f..f20bf80e5f02 100644 --- a/test/modules/deitz/test_module_class_conflict2.good +++ b/test/modules/deitz/test_module_class_conflict2.good @@ -1,2 +1,7 @@ test_module_class_conflict2.chpl:11: In module 'M1': +test_module_class_conflict2.chpl:13: warning: potentially surprising shadowing for 'MC' +test_module_class_conflict2.chpl:12: note: it refers to a symbol found through the 'use' statement here +test_module_class_conflict2.chpl:8: note: and then through the 'use' statement here +test_module_class_conflict2.chpl:2: note: leading to 'MC' defined here +test_module_class_conflict2.chpl:1: note: but, there is a shadowed symbol 'MC' defined here test_module_class_conflict2.chpl:13: error: cannot 'use' symbol 'MC', which is not a module or enum diff --git a/test/modules/deitz/test_module_use4.good b/test/modules/deitz/test_module_use4.good index 76b5d94d102b..77cd51e1bfc6 100644 --- a/test/modules/deitz/test_module_use4.good +++ b/test/modules/deitz/test_module_use4.good @@ -1,2 +1,7 @@ test_module_use4.chpl:10: In module 'M3': +test_module_use4.chpl:12: warning: potentially surprising shadowing for 'M1' +test_module_use4.chpl:11: note: it refers to a symbol found through the 'use' statement here +test_module_use4.chpl:7: note: and then through the 'use' statement here +test_module_use4.chpl:2: note: leading to 'M1' defined here +test_module_use4.chpl:1: note: but, there is a shadowed symbol 'M1' defined here test_module_use4.chpl:12: error: cannot 'use' symbol 'M1', which is not a module or enum diff --git a/test/modules/diten/moduleShadowFormal.good b/test/modules/diten/moduleShadowFormal.good index ccf00d7aa2cf..c7473f4c90fc 100644 --- a/test/modules/diten/moduleShadowFormal.good +++ b/test/modules/diten/moduleShadowFormal.good @@ -1,4 +1,6 @@ moduleShadowFormal.chpl:9: In function 'foo': -moduleShadowFormal.chpl:10: warning: module-level symbol is hiding function argument 'a' -moduleShadowFormal.chpl:2: note: found 'a' defined here +moduleShadowFormal.chpl:11: warning: potentially surprising shadowing for 'a' +moduleShadowFormal.chpl:10: note: it refers to a symbol found through the 'use' statement here +moduleShadowFormal.chpl:2: note: leading to 'a' defined here +moduleShadowFormal.chpl:9: note: but, there is a shadowed symbol 'a' defined here 0 diff --git a/test/modules/diten/test_use_chain_resolution.good b/test/modules/diten/test_use_chain_resolution.good index f6686a75f4ff..de2a9e9ded48 100644 --- a/test/modules/diten/test_use_chain_resolution.good +++ b/test/modules/diten/test_use_chain_resolution.good @@ -1,2 +1,9 @@ +test_use_chain_resolution.chpl:23: In function 'main': +test_use_chain_resolution.chpl:25: warning: potentially surprising shadowing for 'aaa' +test_use_chain_resolution.chpl:24: note: it refers to a symbol found through the 'use' statement here +test_use_chain_resolution.chpl:10: note: and then through the 'use' statement here +test_use_chain_resolution.chpl:6: note: and then through the 'use' statement here +test_use_chain_resolution.chpl:2: note: leading to 'aaa' defined here +test_use_chain_resolution.chpl:22: note: but, there is a shadowed symbol 'aaa' defined here test_use_chain_resolution.chpl:2: error: symbol aaa is multiply defined test_use_chain_resolution.chpl:14: note: also defined here diff --git a/test/modules/diten/test_use_chain_resolution2.good b/test/modules/diten/test_use_chain_resolution2.good index 4a0669728c39..4536289f4ed8 100644 --- a/test/modules/diten/test_use_chain_resolution2.good +++ b/test/modules/diten/test_use_chain_resolution2.good @@ -1,2 +1,8 @@ +test_use_chain_resolution2.chpl:23: In function 'main': +test_use_chain_resolution2.chpl:25: warning: potentially surprising shadowing for 'aaa' +test_use_chain_resolution2.chpl:24: note: it refers to a symbol found through the 'use' statement here +test_use_chain_resolution2.chpl:6: note: and then through the 'use' statement here +test_use_chain_resolution2.chpl:2: note: leading to 'aaa' defined here +test_use_chain_resolution2.chpl:22: note: but, there is a shadowed symbol 'aaa' defined here test_use_chain_resolution2.chpl:2: error: symbol aaa is multiply defined test_use_chain_resolution2.chpl:14: note: also defined here diff --git a/test/modules/noakes/mod-init-fails.good b/test/modules/noakes/mod-init-fails.good index c55034ec9b21..df290439294d 100644 --- a/test/modules/noakes/mod-init-fails.good +++ b/test/modules/noakes/mod-init-fails.good @@ -1,3 +1,13 @@ +mod-init-fails.chpl:1: In module 'Main': +mod-init-fails.chpl:3: warning: potentially surprising shadowing for 'M2' +mod-init-fails.chpl:2: note: it refers to a symbol found through the 'use' statement here +mod-init-fails.chpl:26: note: leading to 'M2' defined here +mod-init-fails.chpl:33: note: but, there is a shadowed symbol 'M2' defined here +mod-init-fails.chpl:61: In module 'M4': +mod-init-fails.chpl:63: warning: potentially surprising shadowing for 'M2' +mod-init-fails.chpl:62: note: it refers to a symbol found through the 'use' statement here +mod-init-fails.chpl:26: note: leading to 'M2' defined here +mod-init-fails.chpl:33: note: but, there is a shadowed symbol 'M2' defined here 1.1: Module M1.M2 1.2: Module M3.M2 1.3: Module M4.M3 diff --git a/test/modules/noakes/mod-init-works.good b/test/modules/noakes/mod-init-works.good index b98c12d2775e..8a17fc712435 100644 --- a/test/modules/noakes/mod-init-works.good +++ b/test/modules/noakes/mod-init-works.good @@ -1,3 +1,8 @@ +mod-init-works.chpl:61: In module 'M4': +mod-init-works.chpl:63: warning: potentially surprising shadowing for 'M2' +mod-init-works.chpl:62: note: it refers to a symbol found through the 'use' statement here +mod-init-works.chpl:26: note: leading to 'M2' defined here +mod-init-works.chpl:33: note: but, there is a shadowed symbol 'M2' defined here 1.1: Module M1.M2 1.2: Module M3.M2 1.3: Module M4.M3 diff --git a/test/modules/shadowing/issue-19167-0.good b/test/modules/shadowing/issue-19167-0.good index cc1d30c19f6e..645dfe68bbb4 100644 --- a/test/modules/shadowing/issue-19167-0.good +++ b/test/modules/shadowing/issue-19167-0.good @@ -1,2 +1,7 @@ +issue-19167-0.chpl:10: In function 'main': +issue-19167-0.chpl:12: warning: potentially surprising shadowing for 'X' +issue-19167-0.chpl:11: note: it refers to a symbol found through the 'use' statement here +issue-19167-0.chpl:2: note: leading to 'X' defined here +issue-19167-0.chpl:7: note: but, there is a shadowed symbol 'X' defined here 0 M.f diff --git a/test/modules/use/topLevel/modNameVsSecondUse.good b/test/modules/use/topLevel/modNameVsSecondUse.good index d81cc0710eb6..dd4f973e56a4 100644 --- a/test/modules/use/topLevel/modNameVsSecondUse.good +++ b/test/modules/use/topLevel/modNameVsSecondUse.good @@ -1 +1,7 @@ +modNameVsSecondUse.chpl:13: In function 'main': +modNameVsSecondUse.chpl:16: warning: potentially surprising shadowing for 'M' +modNameVsSecondUse.chpl:15: note: it refers to a symbol found through the 'use' statement here +modNameVsSecondUse.chpl:9: note: leading to 'M' defined here +modNameVsSecondUse.chpl:14: note: but, there is a shadowed symbol found through the 'use' statement here +modNameVsSecondUse.chpl:1: note: leading to 'M' defined here 42 diff --git a/test/modules/use/topLevel/subVsTop.good b/test/modules/use/topLevel/subVsTop.good index ab7768987ce6..fc6d71fe324c 100644 --- a/test/modules/use/topLevel/subVsTop.good +++ b/test/modules/use/topLevel/subVsTop.good @@ -1 +1,7 @@ +subVsTop.chpl:1: In module 'OuterModule': +subVsTop.chpl:15: warning: potentially surprising shadowing for 'N' +subVsTop.chpl:14: note: it refers to a symbol found through the 'use' statement here +subVsTop.chpl:3: note: leading to 'N' defined here +subVsTop.chpl:13: note: but, there is a shadowed symbol found through the 'use' statement here +subVsTop.chpl:8: note: leading to 'N' defined here M diff --git a/test/modules/use/topLevel/subVsTop1a.good b/test/modules/use/topLevel/subVsTop1a.good index ab7768987ce6..208636d55942 100644 --- a/test/modules/use/topLevel/subVsTop1a.good +++ b/test/modules/use/topLevel/subVsTop1a.good @@ -1 +1,10 @@ +subVsTop1a.chpl:1: In module 'OuterModule': +subVsTop1a.chpl:14: warning: potentially surprising shadowing for 'N' +subVsTop1a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop1a.chpl:3: note: leading to 'N' defined here +subVsTop1a.chpl:8: note: but, there is a shadowed symbol 'N' defined here +subVsTop1a.chpl:15: warning: potentially surprising shadowing for 'N' +subVsTop1a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop1a.chpl:3: note: leading to 'N' defined here +subVsTop1a.chpl:8: note: but, there is a shadowed symbol 'N' defined here M diff --git a/test/modules/use/topLevel/subVsTop2.good b/test/modules/use/topLevel/subVsTop2.good index 29d6383b52c1..c6c8a93c8696 100644 --- a/test/modules/use/topLevel/subVsTop2.good +++ b/test/modules/use/topLevel/subVsTop2.good @@ -1 +1,7 @@ +subVsTop2.chpl:1: In module 'OuterModule': +subVsTop2.chpl:15: warning: potentially surprising shadowing for 'N' +subVsTop2.chpl:14: note: it refers to a symbol found through the 'use' statement here +subVsTop2.chpl:3: note: leading to 'N' defined here +subVsTop2.chpl:13: note: but, there is a shadowed symbol found through the 'use' statement here +subVsTop2.chpl:8: note: leading to 'N' defined here 100 diff --git a/test/modules/use/topLevel/subVsTop2a.good b/test/modules/use/topLevel/subVsTop2a.good index 29d6383b52c1..18bffef22419 100644 --- a/test/modules/use/topLevel/subVsTop2a.good +++ b/test/modules/use/topLevel/subVsTop2a.good @@ -1 +1,10 @@ +subVsTop2a.chpl:1: In module 'OuterModule': +subVsTop2a.chpl:14: warning: potentially surprising shadowing for 'N' +subVsTop2a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop2a.chpl:3: note: leading to 'N' defined here +subVsTop2a.chpl:8: note: but, there is a shadowed symbol 'N' defined here +subVsTop2a.chpl:15: warning: potentially surprising shadowing for 'N' +subVsTop2a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop2a.chpl:3: note: leading to 'N' defined here +subVsTop2a.chpl:8: note: but, there is a shadowed symbol 'N' defined here 100 diff --git a/test/release/examples/primers/modules.good b/test/release/examples/primers/modules.good index 7b620c646892..c217d1248d6f 100644 --- a/test/release/examples/primers/modules.good +++ b/test/release/examples/primers/modules.good @@ -2,7 +2,7 @@ modules.chpl:126: In function 'main': modules.chpl:306: warning: potentially surprising shadowing for 'bar' modules.chpl:305: note: it refers to a symbol found through the 'use' statement here modules.chpl:37: note: leading to 'bar' defined here -modules.chpl:302: note: but there is a shadowed symbol 'bar' defined here +modules.chpl:302: note: but, there is a shadowed symbol 'bar' defined here Start of reverse file-order output This function is accessible! This function is accessible! diff --git a/test/types/enum/lydia/use/exceptList.good b/test/types/enum/lydia/use/exceptList.good index 374b70593cc7..26e1fffe9d19 100644 --- a/test/types/enum/lydia/use/exceptList.good +++ b/test/types/enum/lydia/use/exceptList.good @@ -1,2 +1,7 @@ +exceptList.chpl:11: In function 'main': +exceptList.chpl:14: warning: potentially surprising shadowing for 'paul' +exceptList.chpl:12: note: it refers to a symbol found through the 'use' statement here +exceptList.chpl:4: note: leading to 'paul' defined here +exceptList.chpl:6: note: but, there is a shadowed symbol 'paul' defined here paul clooney diff --git a/test/types/enum/lydia/use/onlyList.good b/test/types/enum/lydia/use/onlyList.good index 374b70593cc7..ca0a867a8d51 100644 --- a/test/types/enum/lydia/use/onlyList.good +++ b/test/types/enum/lydia/use/onlyList.good @@ -1,2 +1,7 @@ +onlyList.chpl:11: In function 'main': +onlyList.chpl:14: warning: potentially surprising shadowing for 'paul' +onlyList.chpl:12: note: it refers to a symbol found through the 'use' statement here +onlyList.chpl:4: note: leading to 'paul' defined here +onlyList.chpl:6: note: but, there is a shadowed symbol 'paul' defined here paul clooney diff --git a/test/types/enum/lydia/use/shadowsOuter.good b/test/types/enum/lydia/use/shadowsOuter.good index 29262413f4ad..3e07e0df3b1b 100644 --- a/test/types/enum/lydia/use/shadowsOuter.good +++ b/test/types/enum/lydia/use/shadowsOuter.good @@ -1,2 +1,11 @@ +shadowsOuter.chpl:12: In function 'main': +shadowsOuter.chpl:15: warning: potentially surprising shadowing for 'paul' +shadowsOuter.chpl:13: note: it refers to a symbol found through the 'use' statement here +shadowsOuter.chpl:5: note: leading to 'paul' defined here +shadowsOuter.chpl:7: note: but, there is a shadowed symbol 'paul' defined here +shadowsOuter.chpl:16: warning: potentially surprising shadowing for 'george' +shadowsOuter.chpl:13: note: it refers to a symbol found through the 'use' statement here +shadowsOuter.chpl:5: note: leading to 'george' defined here +shadowsOuter.chpl:8: note: but, there is a shadowed symbol 'george' defined here paul george diff --git a/test/types/enum/lydia/use/useMultiple.good b/test/types/enum/lydia/use/useMultiple.good index add38ef25f1f..3c4cfa5edfec 100644 --- a/test/types/enum/lydia/use/useMultiple.good +++ b/test/types/enum/lydia/use/useMultiple.good @@ -1,2 +1,8 @@ +useMultiple.chpl:8: In function 'main': +useMultiple.chpl:11: warning: potentially surprising shadowing for 'e' +useMultiple.chpl:9: note: it refers to a symbol found through the 'use' statement here +useMultiple.chpl:6: note: leading to 'e' defined here +useMultiple.chpl:11: note: but, there is a shadowed symbol found in the automatically-included modules +$CHPL_HOME/modules/standard/AutoMath.chpl:125: note: leading to 'e' defined here a b c d e f diff --git a/test/visibility/except/chainNoBlockLaterUse.good b/test/visibility/except/chainNoBlockLaterUse.good index 9d6f253b84ff..8d68cd0652fa 100644 --- a/test/visibility/except/chainNoBlockLaterUse.good +++ b/test/visibility/except/chainNoBlockLaterUse.good @@ -1,3 +1,9 @@ +chainNoBlockLaterUse.chpl:25: In function 'innerCall': +chainNoBlockLaterUse.chpl:28: warning: potentially surprising shadowing for 'foo' +chainNoBlockLaterUse.chpl:27: note: it refers to a symbol found through the 'use' statement here +chainNoBlockLaterUse.chpl:4: note: leading to 'foo' defined here +chainNoBlockLaterUse.chpl:14: note: but, there is a shadowed symbol found through the 'use' statement here +chainNoBlockLaterUse.chpl:9: note: leading to 'foo' defined here false 95.3 14 diff --git a/test/visibility/import/submoduleCloser.bad b/test/visibility/import/submoduleCloser.bad index b48f8a8162d5..b5c3cb5ba9bd 100644 --- a/test/visibility/import/submoduleCloser.bad +++ b/test/visibility/import/submoduleCloser.bad @@ -1,2 +1,6 @@ submoduleCloser.chpl:11: In function 'main': +submoduleCloser.chpl:14: warning: potentially surprising shadowing for 'Details' +submoduleCloser.chpl:13: note: it refers to a symbol found through the 'use' statement here +submoduleCloser.chpl:2: note: leading to 'Details' defined here +submoduleCloser.chpl:6: note: but, there is a shadowed symbol 'Details' defined here submoduleCloser.chpl:15: error: cannot find 'do_my_impl' in module 'Details' diff --git a/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good b/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good index e499f18f742b..c09c46a1d650 100644 --- a/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good +++ b/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good @@ -1,2 +1,6 @@ innerModuleSharesName-topLevel-useInDiffScope.chpl:9: warning: an implicit module named 'innerModuleSharesName-topLevel-useInDiffScope' is being introduced to contain file-scope code +innerModuleSharesName-topLevel-useInDiffScope.chpl:11: warning: potentially surprising shadowing for 'M' +innerModuleSharesName-topLevel-useInDiffScope.chpl:10: note: it refers to a symbol found through the 'use' statement here +innerModuleSharesName-topLevel-useInDiffScope.chpl:2: note: leading to 'M' defined here +innerModuleSharesName-topLevel-useInDiffScope.chpl:1: note: but, there is a shadowed symbol 'M' defined here whee diff --git a/test/visibility/prefer-explicit-use.good b/test/visibility/prefer-explicit-use.good index ee8a39c38d2d..f594a9812882 100644 --- a/test/visibility/prefer-explicit-use.good +++ b/test/visibility/prefer-explicit-use.good @@ -1 +1,7 @@ +prefer-explicit-use.chpl:13: In method 'foo': +prefer-explicit-use.chpl:14: warning: potentially surprising shadowing for 'defaultLowBound' +prefer-explicit-use.chpl:8: note: it refers to a symbol found through the 'use' statement here +prefer-explicit-use.chpl:6: note: leading to 'defaultLowBound' defined here +prefer-explicit-use.chpl:14: note: but, there is a shadowed symbol found in the automatically-included modules +$CHPL_HOME/modules/internal/ChapelBase.chpl:78: note: leading to 'defaultLowBound' defined here string diff --git a/test/visibility/rename/causesShadow.good b/test/visibility/rename/causesShadow.good index c508d5366f70..43603cdb30b7 100644 --- a/test/visibility/rename/causesShadow.good +++ b/test/visibility/rename/causesShadow.good @@ -1 +1,6 @@ +causesShadow.chpl:8: In function 'main': +causesShadow.chpl:11: warning: potentially surprising shadowing for 'bar' +causesShadow.chpl:9: note: it refers to a symbol found through the 'use' statement here +causesShadow.chpl:2: note: leading to 'baz' defined here +causesShadow.chpl:6: note: but, there is a shadowed symbol 'bar' defined here false diff --git a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good index 1ce5dfa83f94..3cd63ec02781 100644 --- a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good +++ b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good @@ -1,3 +1,8 @@ renameSameNameAsInOtherMod.chpl:11: In function 'main': +renameSameNameAsInOtherMod.chpl:12: warning: potentially surprising shadowing for 'Bar' +renameSameNameAsInOtherMod.chpl:9: note: it refers to a symbol found through the 'use' statement here +renameSameNameAsInOtherMod.chpl:5: note: leading to 'Bar' defined here +renameSameNameAsInOtherMod.chpl:8: note: but, there is a shadowed symbol found through the 'use' statement here +renameSameNameAsInOtherMod.chpl:1: note: leading to 'Foo' defined here renameSameNameAsInOtherMod.chpl:12: error: unresolved call 'int(64).x' renameSameNameAsInOtherMod.chpl:12: note: because no functions named x found in scope diff --git a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good index 573541ac9702..c506c8cfb99a 100644 --- a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good +++ b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good @@ -1 +1,7 @@ +renameSameNameAsInOtherMod2.chpl:11: In function 'main': +renameSameNameAsInOtherMod2.chpl:12: warning: potentially surprising shadowing for 'Bar' +renameSameNameAsInOtherMod2.chpl:9: note: it refers to a symbol found through the 'use' statement here +renameSameNameAsInOtherMod2.chpl:5: note: leading to 'Bar' defined here +renameSameNameAsInOtherMod2.chpl:8: note: but, there is a shadowed symbol found through the 'use' statement here +renameSameNameAsInOtherMod2.chpl:1: note: leading to 'Foo' defined here 0 diff --git a/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good b/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good index aa47d0d46d47..7b9eb181679d 100644 --- a/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good +++ b/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good @@ -1,2 +1,7 @@ +renameSameNameConflict3.chpl:7: In module 'User': +renameSameNameConflict3.chpl:11: warning: potentially surprising shadowing for 'L' +renameSameNameConflict3.chpl:8: note: it refers to a symbol found through the 'use' statement here +renameSameNameConflict3.chpl:1: note: leading to 'LongName' defined here +renameSameNameConflict3.chpl:4: note: but, there is a shadowed symbol 'L' defined here 0 0 From 953a244b466228c1902467d2aa821a277c2a83a4 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 13:38:03 -0400 Subject: [PATCH 18/35] Don't warn for an outer scope private use --- Signed-off-by: Michael Ferguson --- frontend/lib/resolution/scope-queries.cpp | 7 ++++++- .../no-warn-use-vs-outer-scope-use.chpl | 15 +++++++++++++++ .../no-warn-use-vs-outer-scope-use.good | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.good diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 8d54c77900e4..ad709ffc1058 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -1195,12 +1195,17 @@ bool LookupHelper::doLookupInScope(const Scope* scope, if (onlyInnermost && got) return true; } - // consider the parent scopes due to nesting + // consider the outer scopes due to nesting if (checkParents) { // create a config that doesn't search parent scopes or toplevel scopes // (such scopes are covered directly later in this function) LookupConfig newConfig = config; newConfig &= ~(LOOKUP_PARENTS|LOOKUP_GO_PAST_MODULES|LOOKUP_TOPLEVEL); + // if we are searching for a warning, ignore anything found through + // a shadow scope in an outer scope + if (checkMoreForWarning) { + newConfig |= LOOKUP_SKIP_SHADOW_SCOPES; + } // Search parent scopes, if any, until a module is encountered const Scope* cur = nullptr; diff --git a/test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.chpl b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.chpl new file mode 100644 index 000000000000..7a32d8a32993 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.chpl @@ -0,0 +1,15 @@ +module A { + var x: int = 1; +} + +module B { + var x: real = 2.2; +} + +module M { + use A; + proc main() { + use B; + writeln(x); + } +} diff --git a/test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.good b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.good new file mode 100644 index 000000000000..8bbe6cf74a1e --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/no-warn-use-vs-outer-scope-use.good @@ -0,0 +1 @@ +2.2 From b362671c9787cae603c24b8f651b6b5f3c77ef77 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 13:46:14 -0400 Subject: [PATCH 19/35] Update tests for error message wording change --- Signed-off-by: Michael Ferguson --- .../unexpected-shadowing-warning/hijacking-example.good | 2 +- .../unexpected-shadowing-warning/private-use-vs-outer.good | 2 +- .../public-private-bring-samename.good | 2 +- .../unexpected-shadowing-warning/public-use-vs-outer.good | 2 +- .../submodule-in-used-vs-submodule.good | 4 ++-- .../submodule-in-used-vs-toplevel-1.good | 2 +- .../submodule-in-used-vs-toplevel-2.good | 2 +- .../submodule-in-used-vs-toplevel-3.good | 2 +- .../submodule-in-used-vs-toplevel-in-file.good | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good index 533e9788d542..5d8651a1a35e 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good @@ -2,6 +2,6 @@ hijacking-example.chpl:19: In function 'main': hijacking-example.chpl:21: warning: potentially surprising shadowing for 'N' hijacking-example.chpl:20: note: it refers to a symbol found through the 'use' statement here hijacking-example.chpl:5: note: leading to 'N' defined here -hijacking-example.chpl:12: note: but there is a shadowed symbol 'N' defined here +hijacking-example.chpl:12: note: but, there is a shadowed symbol 'N' defined here Hijacked! Computing bar() diff --git a/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good index 0982932edd02..5d02f87f20c4 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good @@ -2,5 +2,5 @@ private-use-vs-outer.chpl:7: In function 'main': private-use-vs-outer.chpl:9: warning: potentially surprising shadowing for 'x' private-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' statement here private-use-vs-outer.chpl:2: note: leading to 'x' defined here -private-use-vs-outer.chpl:6: note: but there is a shadowed symbol 'x' defined here +private-use-vs-outer.chpl:6: note: but, there is a shadowed symbol 'x' defined here 42 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good index cbf79ff01d62..2b2668019a1b 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good @@ -2,6 +2,6 @@ public-private-bring-samename.chpl:13: In function 'main': public-private-bring-samename.chpl:14: warning: potentially surprising shadowing for 'x' public-private-bring-samename.chpl:10: note: it refers to a symbol found through the 'use' statement here public-private-bring-samename.chpl:2: note: leading to 'x' defined here -public-private-bring-samename.chpl:11: note: but there is a shadowed symbol found through the 'use' statement here +public-private-bring-samename.chpl:11: note: but, there is a shadowed symbol found through the 'use' statement here public-private-bring-samename.chpl:6: note: leading to 'x' defined here 1 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good index cd9ace7058c9..ee6ef7f8fd0a 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good @@ -2,5 +2,5 @@ public-use-vs-outer.chpl:7: In function 'main': public-use-vs-outer.chpl:9: warning: potentially surprising shadowing for 'x' public-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' statement here public-use-vs-outer.chpl:2: note: leading to 'x' defined here -public-use-vs-outer.chpl:6: note: but there is a shadowed symbol 'x' defined here +public-use-vs-outer.chpl:6: note: but, there is a shadowed symbol 'x' defined here 42 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good index d39195397574..98bd6235ae41 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good @@ -2,9 +2,9 @@ submodule-in-used-vs-submodule.chpl:12: In function 'main': submodule-in-used-vs-submodule.chpl:14: warning: potentially surprising shadowing for 'N' submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' statement here submodule-in-used-vs-submodule.chpl:3: note: leading to 'N' defined here -submodule-in-used-vs-submodule.chpl:8: note: but there is a shadowed symbol 'N' defined here +submodule-in-used-vs-submodule.chpl:8: note: but, there is a shadowed symbol 'N' defined here submodule-in-used-vs-submodule.chpl:15: warning: potentially surprising shadowing for 'N' submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' statement here submodule-in-used-vs-submodule.chpl:3: note: leading to 'N' defined here -submodule-in-used-vs-submodule.chpl:8: note: but there is a shadowed symbol 'N' defined here +submodule-in-used-vs-submodule.chpl:8: note: but, there is a shadowed symbol 'N' defined here 100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good index 20320dddeca6..712f77abc0fc 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good @@ -2,6 +2,6 @@ submodule-in-used-vs-toplevel-1.chpl:14: In function 'main': submodule-in-used-vs-toplevel-1.chpl:15: warning: potentially surprising shadowing for 'N' submodule-in-used-vs-toplevel-1.chpl:13: note: it refers to a symbol found through the 'use' statement here submodule-in-used-vs-toplevel-1.chpl:2: note: leading to 'N' defined here -submodule-in-used-vs-toplevel-1.chpl:12: note: but there is a shadowed symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-1.chpl:12: note: but, there is a shadowed symbol found through the 'use' statement here submodule-in-used-vs-toplevel-1.chpl:7: note: leading to 'N' defined here 100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good index 52750a1fd634..9eccc2f1f854 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good @@ -2,5 +2,5 @@ submodule-in-used-vs-toplevel-2.chpl:11: In module 'Application': submodule-in-used-vs-toplevel-2.chpl:13: warning: potentially surprising shadowing for 'N' submodule-in-used-vs-toplevel-2.chpl:12: note: it refers to a symbol found through the 'use' statement here submodule-in-used-vs-toplevel-2.chpl:2: note: leading to 'N' defined here -submodule-in-used-vs-toplevel-2.chpl:7: note: but there is a shadowed symbol 'N' defined here +submodule-in-used-vs-toplevel-2.chpl:7: note: but, there is a shadowed symbol 'N' defined here 100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good index 47e74b54b44f..a62f558461f8 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good @@ -2,4 +2,4 @@ submodule-in-used-vs-toplevel-3.chpl:12: In function 'main': submodule-in-used-vs-toplevel-3.chpl:14: warning: potentially surprising shadowing for 'N' submodule-in-used-vs-toplevel-3.chpl:13: note: it refers to a symbol found through the 'use' statement here submodule-in-used-vs-toplevel-3.chpl:2: note: leading to 'N' defined here -submodule-in-used-vs-toplevel-3.chpl:7: note: but there is a shadowed symbol 'N' defined here +submodule-in-used-vs-toplevel-3.chpl:7: note: but, there is a shadowed symbol 'N' defined here diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good index b0f2a26a7397..7d28d1a64f60 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good @@ -2,5 +2,5 @@ submodule-in-used-vs-toplevel-in-file.chpl:7: In function 'main': submodule-in-used-vs-toplevel-in-file.chpl:9: warning: potentially surprising shadowing for 'MM' submodule-in-used-vs-toplevel-in-file.chpl:8: note: it refers to a symbol found through the 'use' statement here submodule-in-used-vs-toplevel-in-file.chpl:2: note: leading to 'MM' defined here -MM.chpl:1: note: but there is a shadowed symbol 'MM' defined here +MM.chpl:1: note: but, there is a shadowed symbol 'MM' defined here 0 From ba4c510ec10f2895e13499cf774c936afc0ccfb3 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 14:00:28 -0400 Subject: [PATCH 20/35] remove warning in two cases Generally, the new warning replaces the hidden formal warning, but there are two exceptions here: * The case where a function is found through a use statement but has the same name as a formal is no longer warned about because the new warning does not apply to function lookups (test/functions/iterators/recursive/recursive-iter-findfilesfailure) * The case of a local variable that shadows something from a use statement that in turn shadows a formal is no longer warned about, by the design of the new warning (test/modules/diten/testIfModuleShadowsLocal) --- Signed-off-by: Michael Ferguson --- .../iterators/recursive/recursive-iter-findfilesfailure.good | 3 --- test/modules/diten/testIfModuleShadowsLocal.good | 3 --- 2 files changed, 6 deletions(-) diff --git a/test/functions/iterators/recursive/recursive-iter-findfilesfailure.good b/test/functions/iterators/recursive/recursive-iter-findfilesfailure.good index cafd181c8afb..e69de29bb2d1 100644 --- a/test/functions/iterators/recursive/recursive-iter-findfilesfailure.good +++ b/test/functions/iterators/recursive/recursive-iter-findfilesfailure.good @@ -1,3 +0,0 @@ -recursive-iter-findfilesfailure.chpl:29: In iterator 'mywalkdirs': -recursive-iter-findfilesfailure.chpl:39: warning: module-level symbol is hiding function argument 'sort' -$CHPL_HOME/modules/packages/Sort.chpl:nnnn: note: found 'sort' defined here diff --git a/test/modules/diten/testIfModuleShadowsLocal.good b/test/modules/diten/testIfModuleShadowsLocal.good index 147fa85109eb..ca67c99eda7b 100644 --- a/test/modules/diten/testIfModuleShadowsLocal.good +++ b/test/modules/diten/testIfModuleShadowsLocal.good @@ -1,4 +1 @@ -testIfModuleShadowsLocal.chpl:9: In function 'foo': -testIfModuleShadowsLocal.chpl:11: warning: module-level symbol is hiding function argument 'a' -testIfModuleShadowsLocal.chpl:2: note: found 'a' defined here 1.0 + 2.0i From ba5590821c6798575f1109ed077c5cd65a08aa68 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 29 Sep 2023 14:42:10 -0400 Subject: [PATCH 21/35] Adjust .goods for Don't warn for an outer scope private use --- Signed-off-by: Michael Ferguson --- test/types/enum/lydia/use/useMultiple.good | 6 ------ test/visibility/except/chainNoBlockLaterUse.good | 6 ------ 2 files changed, 12 deletions(-) diff --git a/test/types/enum/lydia/use/useMultiple.good b/test/types/enum/lydia/use/useMultiple.good index 3c4cfa5edfec..add38ef25f1f 100644 --- a/test/types/enum/lydia/use/useMultiple.good +++ b/test/types/enum/lydia/use/useMultiple.good @@ -1,8 +1,2 @@ -useMultiple.chpl:8: In function 'main': -useMultiple.chpl:11: warning: potentially surprising shadowing for 'e' -useMultiple.chpl:9: note: it refers to a symbol found through the 'use' statement here -useMultiple.chpl:6: note: leading to 'e' defined here -useMultiple.chpl:11: note: but, there is a shadowed symbol found in the automatically-included modules -$CHPL_HOME/modules/standard/AutoMath.chpl:125: note: leading to 'e' defined here a b c d e f diff --git a/test/visibility/except/chainNoBlockLaterUse.good b/test/visibility/except/chainNoBlockLaterUse.good index 8d68cd0652fa..9d6f253b84ff 100644 --- a/test/visibility/except/chainNoBlockLaterUse.good +++ b/test/visibility/except/chainNoBlockLaterUse.good @@ -1,9 +1,3 @@ -chainNoBlockLaterUse.chpl:25: In function 'innerCall': -chainNoBlockLaterUse.chpl:28: warning: potentially surprising shadowing for 'foo' -chainNoBlockLaterUse.chpl:27: note: it refers to a symbol found through the 'use' statement here -chainNoBlockLaterUse.chpl:4: note: leading to 'foo' defined here -chainNoBlockLaterUse.chpl:14: note: but, there is a shadowed symbol found through the 'use' statement here -chainNoBlockLaterUse.chpl:9: note: leading to 'foo' defined here false 95.3 14 From c20af97a71640f53bf796d50e5e0f7d2e149a820 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 13:26:48 -0400 Subject: [PATCH 22/35] Don't warn for 'use M only M' etc Don't want to warn when names are named on the use statement; just for the cases where it's a bulk operation. --- Signed-off-by: Michael Ferguson --- frontend/lib/resolution/scope-queries.cpp | 9 +++++---- .../innerModuleSharesName-topLevel-useInDiffScope.good | 4 ---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index ad709ffc1058..603ed3a739a8 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -636,7 +636,7 @@ bool LookupHelper::doLookupInImportsAndUses( bool named = is.lookupName(name, from); if (named && is.kind() == VisibilitySymbols::CONTENTS_EXCEPT) { // mentioned in an except clause, so don't return it - } else if (named + } else if (named // e.g. ONLY_CONTENTS || is.kind() == VisibilitySymbols::ALL_CONTENTS || is.kind() == VisibilitySymbols::CONTENTS_EXCEPT) { // find it in the contents @@ -693,7 +693,7 @@ bool LookupHelper::doLookupInImportsAndUses( // operation like 'use M' if (is.kind() == VisibilitySymbols::ALL_CONTENTS || is.kind() == VisibilitySymbols::CONTENTS_EXCEPT) { - if (foundHere && foundInAllContents) { + if (foundHere && foundInAllContents != nullptr) { *foundInAllContents = true; } } @@ -1141,10 +1141,11 @@ bool LookupHelper::doLookupInScope(const Scope* scope, // now check shadow scope 1 (only relevant for 'private use') if (checkUseImport && !skipShadowScopes) { bool got = false; + bool foundInAll = false; got |= doLookupInImportsAndUses(scope, r, name, config, curFilter, excludeFilter, VisibilitySymbols::SHADOW_SCOPE_ONE, - /* foundInAllContents */ nullptr, + &foundInAll, &foundInShadowScopeOneClauses, /* ignoreClauses */ nullptr); @@ -1154,7 +1155,7 @@ bool LookupHelper::doLookupInScope(const Scope* scope, skipPrivateVisibilities, onlyMethodsFields, includeMethods); - if (got && canCheckMoreForWarning && !checkMoreForWarning) { + if (got && canCheckMoreForWarning && !checkMoreForWarning && foundInAll) { checkMoreForWarning = true; onlyInnermost = false; firstResultForWarning = result.size(); diff --git a/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good b/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good index c09c46a1d650..e499f18f742b 100644 --- a/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good +++ b/test/visibility/only/innerModuleSharesName-topLevel-useInDiffScope.good @@ -1,6 +1,2 @@ innerModuleSharesName-topLevel-useInDiffScope.chpl:9: warning: an implicit module named 'innerModuleSharesName-topLevel-useInDiffScope' is being introduced to contain file-scope code -innerModuleSharesName-topLevel-useInDiffScope.chpl:11: warning: potentially surprising shadowing for 'M' -innerModuleSharesName-topLevel-useInDiffScope.chpl:10: note: it refers to a symbol found through the 'use' statement here -innerModuleSharesName-topLevel-useInDiffScope.chpl:2: note: leading to 'M' defined here -innerModuleSharesName-topLevel-useInDiffScope.chpl:1: note: but, there is a shadowed symbol 'M' defined here whee From ac6791b8da0aa3470bfe60f2c103a5d6605747d0 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 14:41:15 -0400 Subject: [PATCH 23/35] Rename astForIDQuery to astForIdQuery to follow our current capitalization guidance and to be easier to read --- Signed-off-by: Michael Ferguson --- frontend/lib/parsing/parsing-queries.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/lib/parsing/parsing-queries.cpp b/frontend/lib/parsing/parsing-queries.cpp index f636a8f26579..8625929a918a 100644 --- a/frontend/lib/parsing/parsing-queries.cpp +++ b/frontend/lib/parsing/parsing-queries.cpp @@ -909,8 +909,8 @@ const Module* getIncludedSubmodule(Context* context, return getIncludedSubmoduleQuery(context, includeModuleId); } -static const AstNode* const& astForIDQuery(Context* context, ID id) { - QUERY_BEGIN(astForIDQuery, context, id); +static const AstNode* const& astForIdQuery(Context* context, ID id) { + QUERY_BEGIN(astForIdQuery, context, id); const AstNode* result = nullptr; const BuilderResult* r = parseFileContainingIdToBuilderResult(context, id); @@ -927,7 +927,7 @@ const AstNode* idToAst(Context* context, ID id) { return nullptr; } - return astForIDQuery(context, id); + return astForIdQuery(context, id); } // TODO: could many of these get-property-of-ID queries @@ -939,7 +939,7 @@ static const AstTag& idToTagQuery(Context* context, ID id) { AstTag result = asttags::AST_TAG_UNKNOWN; if (!id.isFabricatedId()) { - const AstNode* ast = astForIDQuery(context, id); + const AstNode* ast = astForIdQuery(context, id); if (ast != nullptr) { result = ast->tag(); } else if (types::CompositeType::isMissingBundledRecordType(context, id)) { @@ -963,7 +963,7 @@ static const bool& idIsParenlessFunctionQuery(Context* context, ID id) { AstTag tag = idToTag(context, id); if (asttags::isFunction(tag)) { - const AstNode* ast = astForIDQuery(context, id); + const AstNode* ast = astForIdQuery(context, id); if (ast != nullptr) { if (auto fn = ast->toFunction()) { result = fn->isParenless(); @@ -1026,7 +1026,7 @@ static const bool& idIsMethodQuery(Context* context, ID id) { AstTag tag = idToTag(context, id); if (asttags::isFunction(tag)) { - const AstNode* ast = astForIDQuery(context, id); + const AstNode* ast = astForIdQuery(context, id); if (ast != nullptr) { if (auto fn = ast->toFunction()) { result = fn->isMethod(); @@ -1045,7 +1045,7 @@ static const UniqueString& fieldIdToNameQuery(Context* context, ID id) { QUERY_BEGIN(fieldIdToNameQuery, context, id); UniqueString result; - if (auto ast = astForIDQuery(context, id)) { + if (auto ast = astForIdQuery(context, id)) { if (auto var = ast->toVariable()) { if (var->isField()) { result = var->name(); @@ -1663,7 +1663,7 @@ reportUnstableWarningForId(Context* context, ID idMention, ID idTarget) { static const Module::Kind& getModuleKindQuery(Context* context, ID moduleId) { Module::Kind ret = Module::Kind::DEFAULT_MODULE_KIND; QUERY_BEGIN(getModuleKindQuery, context, moduleId); - const AstNode* ast = astForIDQuery(context, moduleId); + const AstNode* ast = astForIdQuery(context, moduleId); CHPL_ASSERT(ast && "could not find AST for module ID"); if (auto mod = ast->toModule()) { ret = mod->kind(); From 4c69e35338002d99fccc6ece90d485a483d850f6 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 15:04:09 -0400 Subject: [PATCH 24/35] Add context accessor to ErrorWriter --- Signed-off-by: Michael Ferguson --- frontend/include/chpl/framework/ErrorWriter.h | 21 ++++++++++++------- frontend/lib/framework/ErrorBase.cpp | 2 +- frontend/lib/framework/ErrorWriter.cpp | 10 ++++----- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/frontend/include/chpl/framework/ErrorWriter.h b/frontend/include/chpl/framework/ErrorWriter.h index f5bd7016edfb..42cced25e0ff 100644 --- a/frontend/include/chpl/framework/ErrorWriter.h +++ b/frontend/include/chpl/framework/ErrorWriter.h @@ -215,11 +215,11 @@ class ErrorWriterBase { BRIEF, }; protected: - Context* context; + Context* context_; OutputFormat outputFormat_; ErrorWriterBase(Context* context, OutputFormat outputFormat) - : context(context), outputFormat_(outputFormat) {} + : context_(context), outputFormat_(outputFormat) {} /** Makes tweaks to an error string depending on output format. @@ -235,7 +235,7 @@ class ErrorWriterBase { void writeHeading(ErrorBase::Kind kind, ErrorType type, const uast::AstNode* ast, const std::string& message); template void writeHeading(ErrorBase::Kind kind, ErrorType type, errordetail::LocationOnly t, const std::string& message) { - writeHeading(kind, type, errordetail::locate(context, t.t), message); + writeHeading(kind, type, errordetail::locate(context_, t.t), message); } /** @@ -255,7 +255,7 @@ class ErrorWriterBase { void writeNote(const uast::AstNode* ast, const std::string& message); template void writeNote(errordetail::LocationOnly t, const std::string& message) { - writeNote(errordetail::locate(context, t.t), message); + writeNote(errordetail::locate(context_, t.t), message); } /** @@ -271,7 +271,7 @@ class ErrorWriterBase { std::ostringstream oss; auto write = [&](auto t) { errordetail::Writer writer; - writer(context, oss, t); + writer(context_, oss, t); }; auto dummy = { (write(ts), 0)..., }; @@ -355,9 +355,9 @@ class ErrorWriterBase { const std::vector& toHighlight = {}) { std::vector ids(toHighlight.size()); std::transform(toHighlight.cbegin(), toHighlight.cend(), ids.begin(), [&](auto node) { - return errordetail::locate(context, node); + return errordetail::locate(context_, node); }); - writeCode(errordetail::locate(context, place), ids); + writeCode(errordetail::locate(context_, place), ids); } /** @@ -381,6 +381,13 @@ class ErrorWriterBase { void codeForLocation(const LocPlace& place) { code(justOneLine(place)); } + + /** + Return the Context used by this ErrorWriter. + */ + Context* context() { + return context_; + } }; /** diff --git a/frontend/lib/framework/ErrorBase.cpp b/frontend/lib/framework/ErrorBase.cpp index 2046eff06e0d..6aad86936a55 100644 --- a/frontend/lib/framework/ErrorBase.cpp +++ b/frontend/lib/framework/ErrorBase.cpp @@ -58,7 +58,7 @@ class CompatibilityWriter : public ErrorWriterBase { IdOrLocation idOrLoc, const std::string& message) override { // We may not have a context e.g. if we are just figuring out the error // message text. Trust that `computedLoc_` is not important for that. - if (context) this->computedLoc_ = errordetail::locate(context, idOrLoc); + if (context_) this->computedLoc_ = errordetail::locate(context_, idOrLoc); this->idOrLoc_ = std::move(idOrLoc); this->message_ = message; } diff --git a/frontend/lib/framework/ErrorWriter.cpp b/frontend/lib/framework/ErrorWriter.cpp index 9977685e6157..22621cfdc597 100644 --- a/frontend/lib/framework/ErrorWriter.cpp +++ b/frontend/lib/framework/ErrorWriter.cpp @@ -150,7 +150,7 @@ void ErrorWriter::writeHeading(ErrorBase::Kind kind, ErrorType type, // Printing the header prints the file path, so we need to update the // 'lastFilePath_' field. std::string printedPath; - writeFile(context, oss_, errordetail::locate(context, loc), &printedPath); + writeFile(context_, oss_, errordetail::locate(context_, loc), &printedPath); noteFilePath(std::move(printedPath)); if (outputFormat_ == DETAILED) { @@ -174,7 +174,7 @@ void ErrorWriter::writeNote(IdOrLocation loc, const std::string& str) { if (outputFormat_ == BRIEF) { // Indent notes in brief mode to make things easier to organize oss_ << " note in "; - writeFile(context, oss_, errordetail::locate(context, loc)); + writeFile(context_, oss_, errordetail::locate(context_, loc)); oss_ << ": "; } else { // In detailed mode, the body is indented. @@ -197,9 +197,9 @@ static void printLineNo(std::ostream& os, size_t gutterLength, int line) { void ErrorWriter::writeCode(const Location& location, const std::vector& toHighlight) { - if (outputFormat_ != DETAILED || context == nullptr) return; + if (outputFormat_ != DETAILED || context_ == nullptr) return; - auto str = fileText(context, location); + auto str = fileText(context_, location); if (str.empty()) return; ssize_t startIndex = posToFileIndex(str.c_str(), location.firstLine(), 1); @@ -233,7 +233,7 @@ void ErrorWriter::writeCode(const Location& location, // Print the file path if it's changed since the last code block. Printing // a code block will display the file path if needed, so lastFilePath_ needs // to be updated. - if (noteFilePath(locToPath(context, location))) { + if (noteFilePath(locToPath(context_, location))) { printBlank(oss_, codeIndent - 1); oss_ << "--> " << lastFilePath_ << std::endl; } From 702ccc91e403ff6350f9a1e4bf0ad08d2daf262b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 15:04:35 -0400 Subject: [PATCH 25/35] Add parsing::moduleIdToName --- Signed-off-by: Michael Ferguson --- .../include/chpl/parsing/parsing-queries.h | 6 ++++++ frontend/lib/parsing/parsing-queries.cpp | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/frontend/include/chpl/parsing/parsing-queries.h b/frontend/include/chpl/parsing/parsing-queries.h index 5dc52b5e3932..682f0eb6030c 100644 --- a/frontend/include/chpl/parsing/parsing-queries.h +++ b/frontend/include/chpl/parsing/parsing-queries.h @@ -403,6 +403,12 @@ bool idIsMethod(Context* context, ID id); */ UniqueString fieldIdToName(Context* context, ID id); +/** + If the ID represents a Module declaration, return the module name; + otherwise, return the empty string. + */ +UniqueString moduleIdToName(Context* context, ID id); + /** Returns true if the ID is a field in a record/class/union. */ diff --git a/frontend/lib/parsing/parsing-queries.cpp b/frontend/lib/parsing/parsing-queries.cpp index 8625929a918a..a3fd528c8fe3 100644 --- a/frontend/lib/parsing/parsing-queries.cpp +++ b/frontend/lib/parsing/parsing-queries.cpp @@ -1060,6 +1060,24 @@ UniqueString fieldIdToName(Context* context, ID id) { return fieldIdToNameQuery(context, id); } +static const UniqueString& moduleIdToNameQuery(Context* context, ID id) { + QUERY_BEGIN(moduleIdToNameQuery, context, id); + + UniqueString result; + if (auto ast = astForIdQuery(context, id)) { + if (auto mod = ast->toModule()) { + result = mod->name(); + } + } + + return QUERY_END(result); +} + +UniqueString moduleIdToName(Context* context, ID id) { + return moduleIdToNameQuery(context, id); +} + + bool idIsField(Context* context, ID id) { UniqueString name = fieldIdToName(context, id); return !name.isEmpty(); From 538b86bdd403e8f581a195098ac9409bd21ea881 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 15:04:50 -0400 Subject: [PATCH 26/35] Print out module names in use/import traces --- Signed-off-by: Michael Ferguson --- .../include/chpl/resolution/scope-types.h | 2 ++ .../resolution-error-classes-list.cpp | 19 ++++++++++++++++++- frontend/lib/resolution/scope-queries.cpp | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/include/chpl/resolution/scope-types.h b/frontend/include/chpl/resolution/scope-types.h index 996e01290dc5..2a29ce246620 100644 --- a/frontend/include/chpl/resolution/scope-types.h +++ b/frontend/include/chpl/resolution/scope-types.h @@ -1183,6 +1183,7 @@ struct ResultVisibilityTrace { ID visibilityClauseId; VisibilityStmtKind visibilityStmtKind = VIS_USE; UniqueString renameFrom; + const Scope* usedImportedModuleScope = nullptr; bool fromUseImport = false; // this indicates a method receiver scope @@ -1203,6 +1204,7 @@ struct ResultVisibilityTrace { visibilityClauseId == other.visibilityClauseId && visibilityStmtKind == other.visibilityStmtKind && renameFrom == other.renameFrom && + usedImportedModuleScope == other.usedImportedModuleScope && fromUseImport == other.fromUseImport && methodReceiverScope == other.methodReceiverScope && parentScope == other.parentScope && diff --git a/frontend/lib/resolution/resolution-error-classes-list.cpp b/frontend/lib/resolution/resolution-error-classes-list.cpp index 0a31cc49f079..c0349b58db25 100644 --- a/frontend/lib/resolution/resolution-error-classes-list.cpp +++ b/frontend/lib/resolution/resolution-error-classes-list.cpp @@ -126,7 +126,24 @@ static void describeSymbolTrace(ErrorWriterBase& wr, nameSuffix += " providing '" + from.str() + "'"; } - wr.note(locationOnly(elt.visibilityClauseId), errbegin, " the '", elt.visibilityStmtKind, "' statement", nameSuffix, " here:"); + std::string useImpStmt = ""; + if (elt.visibilityStmtKind == resolution::VisibilityStmtKind::VIS_USE) + useImpStmt = "use"; + else + useImpStmt = "import"; + + if (elt.usedImportedModuleScope != nullptr) { + ID usedImportedModId = elt.usedImportedModuleScope->id(); + if (!usedImportedModId.isEmpty()) { + // compute the name + UniqueString modName = parsing::moduleIdToName(wr.context(), + usedImportedModId); + useImpStmt += " "; + useImpStmt += modName.str(); + } + } + wr.note(locationOnly(elt.visibilityClauseId), errbegin, + " the '", useImpStmt, "' statement", nameSuffix, " here:"); wr.code(elt.visibilityClauseId, { elt.visibilityClauseId }); from = elt.renameFrom; needsIntroText = false; diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 603ed3a739a8..41ad68f6e05a 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -683,6 +683,7 @@ bool LookupHelper::doLookupInImportsAndUses( elt.visibilityStmtKind = getKindForVisibilityClauseId(context, elt.visibilityClauseId); elt.renameFrom = nameToLookUp; + elt.usedImportedModuleScope = is.scope(); elt.fromUseImport = true; traceCurPath->push_back(std::move(elt)); } @@ -730,6 +731,7 @@ bool LookupHelper::doLookupInImportsAndUses( elt.visibilityStmtKind = getKindForVisibilityClauseId(context, elt.visibilityClauseId); elt.renameFrom = from; + elt.usedImportedModuleScope = is.scope(); elt.fromUseImport = true; t.visibleThrough.push_back(std::move(elt)); traceResult->push_back(std::move(t)); From 938259d11f6a03334ee89e6335703794e0949e33 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 15:37:38 -0400 Subject: [PATCH 27/35] Take out ErrorWriter::context(), improve wording ErrorWriter::context() is problematic because the Context* can be nullptr in some situations. --- Signed-off-by: Michael Ferguson --- frontend/include/chpl/framework/ErrorWriter.h | 9 +----- .../include/chpl/resolution/scope-types.h | 2 ++ .../resolution-error-classes-list.cpp | 28 ++++++++----------- frontend/lib/resolution/scope-queries.cpp | 2 ++ 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/frontend/include/chpl/framework/ErrorWriter.h b/frontend/include/chpl/framework/ErrorWriter.h index 42cced25e0ff..e0217fe24116 100644 --- a/frontend/include/chpl/framework/ErrorWriter.h +++ b/frontend/include/chpl/framework/ErrorWriter.h @@ -215,7 +215,7 @@ class ErrorWriterBase { BRIEF, }; protected: - Context* context_; + Context* context_; // note: this can sometimes be null OutputFormat outputFormat_; ErrorWriterBase(Context* context, OutputFormat outputFormat) @@ -381,13 +381,6 @@ class ErrorWriterBase { void codeForLocation(const LocPlace& place) { code(justOneLine(place)); } - - /** - Return the Context used by this ErrorWriter. - */ - Context* context() { - return context_; - } }; /** diff --git a/frontend/include/chpl/resolution/scope-types.h b/frontend/include/chpl/resolution/scope-types.h index 2a29ce246620..0608ee93d1b3 100644 --- a/frontend/include/chpl/resolution/scope-types.h +++ b/frontend/include/chpl/resolution/scope-types.h @@ -1183,6 +1183,7 @@ struct ResultVisibilityTrace { ID visibilityClauseId; VisibilityStmtKind visibilityStmtKind = VIS_USE; UniqueString renameFrom; + UniqueString moduleName; const Scope* usedImportedModuleScope = nullptr; bool fromUseImport = false; @@ -1204,6 +1205,7 @@ struct ResultVisibilityTrace { visibilityClauseId == other.visibilityClauseId && visibilityStmtKind == other.visibilityStmtKind && renameFrom == other.renameFrom && + moduleName == other.moduleName && usedImportedModuleScope == other.usedImportedModuleScope && fromUseImport == other.fromUseImport && methodReceiverScope == other.methodReceiverScope && diff --git a/frontend/lib/resolution/resolution-error-classes-list.cpp b/frontend/lib/resolution/resolution-error-classes-list.cpp index c0349b58db25..977e3333ec9c 100644 --- a/frontend/lib/resolution/resolution-error-classes-list.cpp +++ b/frontend/lib/resolution/resolution-error-classes-list.cpp @@ -116,34 +116,28 @@ static void describeSymbolTrace(ErrorWriterBase& wr, } else if (elt.fromUseImport) { std::string errbegin; std::string nameSuffix; + if (start==0 && needsIntroText) { errbegin = intro; errbegin += "through"; } else { - errbegin = "and then through"; + errbegin = "and then "; + errbegin += "through"; } if (from != name) { nameSuffix += " providing '" + from.str() + "'"; } - std::string useImpStmt = ""; - if (elt.visibilityStmtKind == resolution::VisibilityStmtKind::VIS_USE) - useImpStmt = "use"; - else - useImpStmt = "import"; - - if (elt.usedImportedModuleScope != nullptr) { - ID usedImportedModId = elt.usedImportedModuleScope->id(); - if (!usedImportedModId.isEmpty()) { - // compute the name - UniqueString modName = parsing::moduleIdToName(wr.context(), - usedImportedModId); - useImpStmt += " "; - useImpStmt += modName.str(); - } + std::string of; + if (!elt.moduleName.isEmpty()) { + of += "of '"; + of += elt.moduleName.str(); + of += "' "; } + wr.note(locationOnly(elt.visibilityClauseId), errbegin, - " the '", useImpStmt, "' statement", nameSuffix, " here:"); + " the '", elt.visibilityStmtKind, "' ", of, + nameSuffix, " here:"); wr.code(elt.visibilityClauseId, { elt.visibilityClauseId }); from = elt.renameFrom; needsIntroText = false; diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 41ad68f6e05a..1756b3e45141 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -683,6 +683,7 @@ bool LookupHelper::doLookupInImportsAndUses( elt.visibilityStmtKind = getKindForVisibilityClauseId(context, elt.visibilityClauseId); elt.renameFrom = nameToLookUp; + elt.moduleName = parsing::moduleIdToName(context, is.scope()->id()); elt.usedImportedModuleScope = is.scope(); elt.fromUseImport = true; traceCurPath->push_back(std::move(elt)); @@ -731,6 +732,7 @@ bool LookupHelper::doLookupInImportsAndUses( elt.visibilityStmtKind = getKindForVisibilityClauseId(context, elt.visibilityClauseId); elt.renameFrom = from; + elt.moduleName = parsing::moduleIdToName(context, is.scope()->id()); elt.usedImportedModuleScope = is.scope(); elt.fromUseImport = true; t.visibleThrough.push_back(std::move(elt)); From de120857bc9cc519b01795700c0530720bfbf896 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 16:05:01 -0400 Subject: [PATCH 28/35] Fix missing fields in mark --- Signed-off-by: Michael Ferguson --- frontend/include/chpl/resolution/scope-types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/include/chpl/resolution/scope-types.h b/frontend/include/chpl/resolution/scope-types.h index 0608ee93d1b3..ab8220ab891a 100644 --- a/frontend/include/chpl/resolution/scope-types.h +++ b/frontend/include/chpl/resolution/scope-types.h @@ -1221,6 +1221,8 @@ struct ResultVisibilityTrace { void mark(Context* context) const { context->markPointer(resolvedVisibilityScope); renameFrom.mark(context); + moduleName.mark(context); + context->markPointer(usedImportedModuleScope); visibilityClauseId.mark(context); context->markPointer(methodReceiverScope); context->markPointer(parentScope); From 46f98d570faba626036c323877f9efab0ffc7a2d Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 16:57:11 -0400 Subject: [PATCH 29/35] Improve error message wording & enum handling --- Signed-off-by: Michael Ferguson --- .../include/chpl/parsing/parsing-queries.h | 6 ------ frontend/include/chpl/resolution/scope-types.h | 12 ++++++------ frontend/lib/parsing/parsing-queries.cpp | 18 ------------------ .../resolution-error-classes-list.cpp | 12 +++++++----- frontend/lib/resolution/scope-queries.cpp | 8 ++++---- 5 files changed, 17 insertions(+), 39 deletions(-) diff --git a/frontend/include/chpl/parsing/parsing-queries.h b/frontend/include/chpl/parsing/parsing-queries.h index 682f0eb6030c..5dc52b5e3932 100644 --- a/frontend/include/chpl/parsing/parsing-queries.h +++ b/frontend/include/chpl/parsing/parsing-queries.h @@ -403,12 +403,6 @@ bool idIsMethod(Context* context, ID id); */ UniqueString fieldIdToName(Context* context, ID id); -/** - If the ID represents a Module declaration, return the module name; - otherwise, return the empty string. - */ -UniqueString moduleIdToName(Context* context, ID id); - /** Returns true if the ID is a field in a record/class/union. */ diff --git a/frontend/include/chpl/resolution/scope-types.h b/frontend/include/chpl/resolution/scope-types.h index ab8220ab891a..e973162aae32 100644 --- a/frontend/include/chpl/resolution/scope-types.h +++ b/frontend/include/chpl/resolution/scope-types.h @@ -1183,8 +1183,8 @@ struct ResultVisibilityTrace { ID visibilityClauseId; VisibilityStmtKind visibilityStmtKind = VIS_USE; UniqueString renameFrom; - UniqueString moduleName; - const Scope* usedImportedModuleScope = nullptr; + UniqueString usedImportedThingName; + const Scope* usedImportedScope = nullptr; bool fromUseImport = false; // this indicates a method receiver scope @@ -1205,8 +1205,8 @@ struct ResultVisibilityTrace { visibilityClauseId == other.visibilityClauseId && visibilityStmtKind == other.visibilityStmtKind && renameFrom == other.renameFrom && - moduleName == other.moduleName && - usedImportedModuleScope == other.usedImportedModuleScope && + usedImportedThingName == other.usedImportedThingName && + usedImportedScope == other.usedImportedScope && fromUseImport == other.fromUseImport && methodReceiverScope == other.methodReceiverScope && parentScope == other.parentScope && @@ -1221,8 +1221,8 @@ struct ResultVisibilityTrace { void mark(Context* context) const { context->markPointer(resolvedVisibilityScope); renameFrom.mark(context); - moduleName.mark(context); - context->markPointer(usedImportedModuleScope); + usedImportedThingName.mark(context); + context->markPointer(usedImportedScope); visibilityClauseId.mark(context); context->markPointer(methodReceiverScope); context->markPointer(parentScope); diff --git a/frontend/lib/parsing/parsing-queries.cpp b/frontend/lib/parsing/parsing-queries.cpp index a3fd528c8fe3..8625929a918a 100644 --- a/frontend/lib/parsing/parsing-queries.cpp +++ b/frontend/lib/parsing/parsing-queries.cpp @@ -1060,24 +1060,6 @@ UniqueString fieldIdToName(Context* context, ID id) { return fieldIdToNameQuery(context, id); } -static const UniqueString& moduleIdToNameQuery(Context* context, ID id) { - QUERY_BEGIN(moduleIdToNameQuery, context, id); - - UniqueString result; - if (auto ast = astForIdQuery(context, id)) { - if (auto mod = ast->toModule()) { - result = mod->name(); - } - } - - return QUERY_END(result); -} - -UniqueString moduleIdToName(Context* context, ID id) { - return moduleIdToNameQuery(context, id); -} - - bool idIsField(Context* context, ID id) { UniqueString name = fieldIdToName(context, id); return !name.isEmpty(); diff --git a/frontend/lib/resolution/resolution-error-classes-list.cpp b/frontend/lib/resolution/resolution-error-classes-list.cpp index 977e3333ec9c..9f08f3835fd3 100644 --- a/frontend/lib/resolution/resolution-error-classes-list.cpp +++ b/frontend/lib/resolution/resolution-error-classes-list.cpp @@ -129,14 +129,16 @@ static void describeSymbolTrace(ErrorWriterBase& wr, } std::string of; - if (!elt.moduleName.isEmpty()) { - of += "of '"; - of += elt.moduleName.str(); - of += "' "; + if (!elt.usedImportedThingName.isEmpty()) { + of += " of '"; + of += elt.usedImportedThingName.str(); + of += "'"; + } else { + of = " statement"; } wr.note(locationOnly(elt.visibilityClauseId), errbegin, - " the '", elt.visibilityStmtKind, "' ", of, + " the '", elt.visibilityStmtKind, "'", of, nameSuffix, " here:"); wr.code(elt.visibilityClauseId, { elt.visibilityClauseId }); from = elt.renameFrom; diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index 1756b3e45141..b9ceac4a848d 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -683,8 +683,8 @@ bool LookupHelper::doLookupInImportsAndUses( elt.visibilityStmtKind = getKindForVisibilityClauseId(context, elt.visibilityClauseId); elt.renameFrom = nameToLookUp; - elt.moduleName = parsing::moduleIdToName(context, is.scope()->id()); - elt.usedImportedModuleScope = is.scope(); + elt.usedImportedThingName = is.scope()->id().symbolName(context); + elt.usedImportedScope = is.scope(); elt.fromUseImport = true; traceCurPath->push_back(std::move(elt)); } @@ -732,8 +732,8 @@ bool LookupHelper::doLookupInImportsAndUses( elt.visibilityStmtKind = getKindForVisibilityClauseId(context, elt.visibilityClauseId); elt.renameFrom = from; - elt.moduleName = parsing::moduleIdToName(context, is.scope()->id()); - elt.usedImportedModuleScope = is.scope(); + elt.usedImportedThingName = is.scope()->id().symbolName(context); + elt.usedImportedScope = is.scope(); elt.fromUseImport = true; t.visibleThrough.push_back(std::move(elt)); traceResult->push_back(std::move(t)); From 492f68ce631242ee83d7c7b37577248ec6f65337 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 16:58:31 -0400 Subject: [PATCH 30/35] Add test of error message with enum --- Signed-off-by: Michael Ferguson --- .../private-use-enum-vs-outer.chpl | 10 ++++++++++ .../private-use-enum-vs-outer.good | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.chpl create mode 100644 test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.good diff --git a/test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.chpl b/test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.chpl new file mode 100644 index 000000000000..ff16d94471fa --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.chpl @@ -0,0 +1,10 @@ +module N { + enum myEnum { x = 1 } + + var x: real; + proc main() { + private use myEnum; + writeln(x); + } +} + diff --git a/test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.good new file mode 100644 index 000000000000..e4a0c6ee6be2 --- /dev/null +++ b/test/modules/shadowing/unexpected-shadowing-warning/private-use-enum-vs-outer.good @@ -0,0 +1,6 @@ +private-use-enum-vs-outer.chpl:5: In function 'main': +private-use-enum-vs-outer.chpl:7: warning: potentially surprising shadowing for 'x' +private-use-enum-vs-outer.chpl:6: note: it refers to a symbol found through the 'use' of 'myEnum' here +private-use-enum-vs-outer.chpl:2: note: leading to 'x' defined here +private-use-enum-vs-outer.chpl:4: note: but, there is a shadowed symbol 'x' defined here +x From 238abcd03b828dc81a183b361ef635a8ee9b3676 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 2 Oct 2023 17:12:52 -0400 Subject: [PATCH 31/35] Update tests with current warning/error wording --- Signed-off-by: Michael Ferguson --- test/deprecated-keyword/handleEnum.good | 4 ++-- .../redefinition-def-with-public-import.1.good | 2 +- .../redefinition-def-with-public-import.2.good | 2 +- .../redefinition-def-with-public-use.1.good | 2 +- .../redefinition-def-with-public-use.2.good | 2 +- .../redefinition/redefinition-private-import.1.good | 4 ++-- .../redefinition/redefinition-private-import.2.good | 4 ++-- .../redefinition/redefinition-public-import.1.good | 4 ++-- .../redefinition/redefinition-public-import.2.good | 4 ++-- .../redefinition/redefinition-public-use-as.1.good | 4 ++-- .../redefinition/redefinition-public-use-as.2.good | 4 ++-- .../redefinition/redefinition-public-use.1.good | 4 ++-- .../redefinition/redefinition-public-use.2.good | 4 ++-- .../scope-resolution/use-shadows-formal1.1-0.good | 4 ++-- .../scope-resolution/use-shadows-formal1.2-0.good | 4 ++-- .../errors/scope-resolution/use-shadows-formal2.1.good | 4 ++-- .../errors/scope-resolution/use-shadows-formal2.2.good | 4 ++-- test/modules/deitz/test_module_class_conflict2.good | 4 ++-- test/modules/deitz/test_module_use4.good | 4 ++-- test/modules/diten/moduleShadowFormal.good | 2 +- test/modules/diten/test_use_chain_resolution.good | 6 +++--- test/modules/diten/test_use_chain_resolution2.good | 4 ++-- .../DuplicateConfigVars/DuplicateConfigVars.good | 10 +++++----- test/modules/noakes/mod-init-fails.good | 4 ++-- test/modules/noakes/mod-init-works.good | 2 +- test/modules/shadowing/issue-19167-0.good | 2 +- test/modules/shadowing/issue-19167-1-x.good | 4 ++-- test/modules/shadowing/issue-19167-2-x.good | 6 +++--- test/modules/shadowing/issue-19167-3-x.good | 2 +- test/modules/shadowing/issue-19167-4-x.good | 8 ++++---- test/modules/shadowing/issue-19167-5-x.good | 8 ++++---- .../hijacking-example.good | 2 +- .../public-private-bring-samename.good | 4 ++-- .../public-use-vs-outer.good | 2 +- .../submodule-in-used-vs-submodule.good | 4 ++-- .../submodule-in-used-vs-toplevel-1.good | 4 ++-- .../submodule-in-used-vs-toplevel-2.good | 2 +- .../submodule-in-used-vs-toplevel-3.good | 2 +- .../submodule-in-used-vs-toplevel-in-file.good | 2 +- test/modules/shadowing/var-shadows-private-import.good | 2 +- test/modules/shadowing/var-shadows-public-import.good | 2 +- test/modules/shadowing/var-shadows-public-use.good | 2 +- test/modules/use/topLevel/modNameVsSecondUse.good | 4 ++-- test/modules/use/topLevel/subVsTop.good | 4 ++-- test/modules/use/topLevel/subVsTop1a.good | 4 ++-- test/modules/use/topLevel/subVsTop2.good | 4 ++-- test/modules/use/topLevel/subVsTop2a.good | 4 ++-- test/release/examples/primers/modules.good | 2 +- test/types/enum/lydia/use/exceptList.good | 2 +- test/types/enum/lydia/use/onlyList.good | 5 ----- test/types/enum/lydia/use/shadowsOuter.good | 4 ++-- .../import/edgeCases/anotherMultipleDef2.good | 4 ++-- test/visibility/import/edgeCases/multipleDef2.good | 4 ++-- test/visibility/import/edgeCases/multipleDef3.good | 4 ++-- test/visibility/import/rename/same_name_in_mod.good | 2 +- test/visibility/import/rename/same_name_in_mod2.good | 2 +- test/visibility/import/submoduleCloser.bad | 2 +- test/visibility/prefer-explicit-use.good | 2 +- test/visibility/rename/causesShadow.good | 5 ----- .../renameUsedMod/renameSameNameAsInOtherMod.good | 4 ++-- .../renameUsedMod/renameSameNameAsInOtherMod2.good | 4 ++-- .../rename/renameUsedMod/renameSameNameConflict3.good | 2 +- 62 files changed, 106 insertions(+), 116 deletions(-) diff --git a/test/deprecated-keyword/handleEnum.good b/test/deprecated-keyword/handleEnum.good index e914db08e912..8f7d45663928 100644 --- a/test/deprecated-keyword/handleEnum.good +++ b/test/deprecated-keyword/handleEnum.good @@ -4,11 +4,11 @@ handleEnum.chpl:7: warning: Enum e is deprecated, use enum f handleEnum.chpl:8: warning: Enum e is deprecated, use enum f handleEnum.chpl:12: warning: Enum e is deprecated, use enum f handleEnum.chpl:14: warning: potentially surprising shadowing for 'a' -handleEnum.chpl:12: note: it refers to a symbol found through the 'use' statement here +handleEnum.chpl:12: note: it refers to a symbol found through the 'use' of 'e' here handleEnum.chpl:2: note: leading to 'a' defined here handleEnum.chpl:6: note: but, there is a shadowed symbol 'a' defined here handleEnum.chpl:16: warning: potentially surprising shadowing for 'c' -handleEnum.chpl:12: note: it refers to a symbol found through the 'use' statement here +handleEnum.chpl:12: note: it refers to a symbol found through the 'use' of 'e' here handleEnum.chpl:2: note: leading to 'c' defined here handleEnum.chpl:8: note: but, there is a shadowed symbol 'c' defined here b diff --git a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.1.good b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.1.good index f04adc76a260..3b026b33b3c4 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.1.good +++ b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.1.good @@ -1,4 +1,4 @@ redefinition-def-with-public-import.chpl:4: In module 'T2': redefinition-def-with-public-import.chpl:6: error: 'a' has multiple definitions -redefinition-def-with-public-import.chpl:5: note: redefined through the 'import' statement here +redefinition-def-with-public-import.chpl:5: note: redefined through the 'import' of 'Lib1' here redefinition-def-with-public-import.chpl:2: note: leading to the definition here diff --git a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.2.good b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.2.good index fc512f0d1a63..60886c76a532 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.2.good +++ b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-import.2.good @@ -5,7 +5,7 @@ 6 | var a: real; | ⎺⎺⎺⎺⎺⎺⎺⎺ | - Redefined through the 'import' statement here: + Redefined through the 'import' of 'Lib1' here: | 5 | public import Lib1.a; | ⎺⎺⎺⎺⎺⎺ diff --git a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.1.good b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.1.good index 154c97ca4d7a..f67216c013fd 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.1.good +++ b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.1.good @@ -1,4 +1,4 @@ redefinition-def-with-public-use.chpl:4: In module 'T2': redefinition-def-with-public-use.chpl:6: error: 'a' has multiple definitions -redefinition-def-with-public-use.chpl:5: note: redefined through the 'use' statement here +redefinition-def-with-public-use.chpl:5: note: redefined through the 'use' of 'Lib1' here redefinition-def-with-public-use.chpl:2: note: leading to the definition here diff --git a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.2.good b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.2.good index 170ed90de282..50b85b55694e 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.2.good +++ b/test/errors/scope-resolution/redefinition/redefinition-def-with-public-use.2.good @@ -5,7 +5,7 @@ 6 | var a: real; | ⎺⎺⎺⎺⎺⎺⎺⎺ | - Redefined through the 'use' statement here: + Redefined through the 'use' of 'Lib1' here: | 5 | public use Lib1; | ⎺⎺⎺⎺ diff --git a/test/errors/scope-resolution/redefinition/redefinition-private-import.1.good b/test/errors/scope-resolution/redefinition/redefinition-private-import.1.good index e59e4c567ed0..63a8ea08bfd2 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-private-import.1.good +++ b/test/errors/scope-resolution/redefinition/redefinition-private-import.1.good @@ -1,5 +1,5 @@ redefinition-private-import.chpl:9: error: 'a' has multiple definitions in this scope -redefinition-private-import.chpl:10: note: it was first defined through the 'import' statement here +redefinition-private-import.chpl:10: note: it was first defined through the 'import' of 'Lib1' here redefinition-private-import.chpl:2: note: leading to the definition here -redefinition-private-import.chpl:10: note: redefined through the 'import' statement here +redefinition-private-import.chpl:10: note: redefined through the 'import' of 'Lib2' here redefinition-private-import.chpl:6: note: leading to the definition here diff --git a/test/errors/scope-resolution/redefinition/redefinition-private-import.2.good b/test/errors/scope-resolution/redefinition/redefinition-private-import.2.good index 89dbeb2c2de3..d01af83e0ba4 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-private-import.2.good +++ b/test/errors/scope-resolution/redefinition/redefinition-private-import.2.good @@ -1,6 +1,6 @@ ─── error in redefinition-private-import.chpl:9 [Redefinition] ─── 'a' has multiple definitions in this scope. - It was first defined through the 'import' statement here: + It was first defined through the 'import' of 'Lib1' here: | 10 | private import Lib1.a, Lib2.a; | ⎺⎺⎺⎺⎺⎺ @@ -10,7 +10,7 @@ 2 | var a: int; | ⎺⎺⎺⎺⎺⎺⎺ | - Redefined through the 'import' statement here: + Redefined through the 'import' of 'Lib2' here: | 10 | private import Lib1.a, Lib2.a; | ⎺⎺⎺⎺⎺⎺ diff --git a/test/errors/scope-resolution/redefinition/redefinition-public-import.1.good b/test/errors/scope-resolution/redefinition/redefinition-public-import.1.good index 74d9631a81e4..fa0cd24c3215 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-public-import.1.good +++ b/test/errors/scope-resolution/redefinition/redefinition-public-import.1.good @@ -1,5 +1,5 @@ redefinition-public-import.chpl:9: error: 'a' has multiple definitions in this scope -redefinition-public-import.chpl:10: note: it was first defined through the 'import' statement here +redefinition-public-import.chpl:10: note: it was first defined through the 'import' of 'Lib1' here redefinition-public-import.chpl:2: note: leading to the definition here -redefinition-public-import.chpl:10: note: redefined through the 'import' statement here +redefinition-public-import.chpl:10: note: redefined through the 'import' of 'Lib2' here redefinition-public-import.chpl:6: note: leading to the definition here diff --git a/test/errors/scope-resolution/redefinition/redefinition-public-import.2.good b/test/errors/scope-resolution/redefinition/redefinition-public-import.2.good index e77f51d44f8d..c83fd3c3a84c 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-public-import.2.good +++ b/test/errors/scope-resolution/redefinition/redefinition-public-import.2.good @@ -1,6 +1,6 @@ ─── error in redefinition-public-import.chpl:9 [Redefinition] ─── 'a' has multiple definitions in this scope. - It was first defined through the 'import' statement here: + It was first defined through the 'import' of 'Lib1' here: | 10 | public import Lib1.a, Lib2.a; | ⎺⎺⎺⎺⎺⎺ @@ -10,7 +10,7 @@ 2 | var a: int; | ⎺⎺⎺⎺⎺⎺⎺ | - Redefined through the 'import' statement here: + Redefined through the 'import' of 'Lib2' here: | 10 | public import Lib1.a, Lib2.a; | ⎺⎺⎺⎺⎺⎺ diff --git a/test/errors/scope-resolution/redefinition/redefinition-public-use-as.1.good b/test/errors/scope-resolution/redefinition/redefinition-public-use-as.1.good index bf0b6a851938..8e863d651497 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-public-use-as.1.good +++ b/test/errors/scope-resolution/redefinition/redefinition-public-use-as.1.good @@ -1,5 +1,5 @@ redefinition-public-use-as.chpl:9: error: 'a' has multiple definitions in this scope -redefinition-public-use-as.chpl:10: note: it was first defined through the 'use' statement here +redefinition-public-use-as.chpl:10: note: it was first defined through the 'use' of 'Lib1' here redefinition-public-use-as.chpl:2: note: leading to the definition here -redefinition-public-use-as.chpl:11: note: redefined through the 'use' statement here +redefinition-public-use-as.chpl:11: note: redefined through the 'use' of 'Lib2' here redefinition-public-use-as.chpl:6: note: leading to the definition here diff --git a/test/errors/scope-resolution/redefinition/redefinition-public-use-as.2.good b/test/errors/scope-resolution/redefinition/redefinition-public-use-as.2.good index 6ad6bf4b54b8..98bc5c350746 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-public-use-as.2.good +++ b/test/errors/scope-resolution/redefinition/redefinition-public-use-as.2.good @@ -1,6 +1,6 @@ ─── error in redefinition-public-use-as.chpl:9 [Redefinition] ─── 'a' has multiple definitions in this scope. - It was first defined through the 'use' statement here: + It was first defined through the 'use' of 'Lib1' here: | 10 | public use Lib1; | ⎺⎺⎺⎺ @@ -10,7 +10,7 @@ 2 | var a: int; | ⎺⎺⎺⎺⎺⎺⎺ | - Redefined through the 'use' statement here: + Redefined through the 'use' of 'Lib2' here: | 11 | public use Lib2 only b as a; | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ diff --git a/test/errors/scope-resolution/redefinition/redefinition-public-use.1.good b/test/errors/scope-resolution/redefinition/redefinition-public-use.1.good index f135ab919426..e6ec062a8bde 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-public-use.1.good +++ b/test/errors/scope-resolution/redefinition/redefinition-public-use.1.good @@ -1,5 +1,5 @@ redefinition-public-use.chpl:9: error: 'a' has multiple definitions in this scope -redefinition-public-use.chpl:10: note: it was first defined through the 'use' statement here +redefinition-public-use.chpl:10: note: it was first defined through the 'use' of 'Lib1' here redefinition-public-use.chpl:2: note: leading to the definition here -redefinition-public-use.chpl:10: note: redefined through the 'use' statement here +redefinition-public-use.chpl:10: note: redefined through the 'use' of 'Lib2' here redefinition-public-use.chpl:6: note: leading to the definition here diff --git a/test/errors/scope-resolution/redefinition/redefinition-public-use.2.good b/test/errors/scope-resolution/redefinition/redefinition-public-use.2.good index fa3de7f50836..5299b1476497 100644 --- a/test/errors/scope-resolution/redefinition/redefinition-public-use.2.good +++ b/test/errors/scope-resolution/redefinition/redefinition-public-use.2.good @@ -1,6 +1,6 @@ ─── error in redefinition-public-use.chpl:9 [Redefinition] ─── 'a' has multiple definitions in this scope. - It was first defined through the 'use' statement here: + It was first defined through the 'use' of 'Lib1' here: | 10 | public use Lib1, Lib2; | ⎺⎺⎺⎺ @@ -10,7 +10,7 @@ 2 | var a: int; | ⎺⎺⎺⎺⎺⎺⎺ | - Redefined through the 'use' statement here: + Redefined through the 'use' of 'Lib2' here: | 10 | public use Lib1, Lib2; | ⎺⎺⎺⎺ diff --git a/test/errors/scope-resolution/use-shadows-formal1.1-0.good b/test/errors/scope-resolution/use-shadows-formal1.1-0.good index a931d8bcdff7..5212e0a3de3b 100644 --- a/test/errors/scope-resolution/use-shadows-formal1.1-0.good +++ b/test/errors/scope-resolution/use-shadows-formal1.1-0.good @@ -1,7 +1,7 @@ use-shadows-formal1.chpl:13: In function 'foo': use-shadows-formal1.chpl:15: warning: potentially surprising shadowing for 'a' -use-shadows-formal1.chpl:14: note: it refers to a symbol found through the 'use' statement here -use-shadows-formal1.chpl:6: note: and then through the 'use' statement here +use-shadows-formal1.chpl:14: note: it refers to a symbol found through the 'use' of 'M1' here +use-shadows-formal1.chpl:6: note: and then through the 'use' of 'M0' here use-shadows-formal1.chpl:2: note: leading to 'b' defined here use-shadows-formal1.chpl:13: note: but, there is a shadowed symbol 'a' defined here 0 diff --git a/test/errors/scope-resolution/use-shadows-formal1.2-0.good b/test/errors/scope-resolution/use-shadows-formal1.2-0.good index 73a014cc79b3..1e9593669e67 100644 --- a/test/errors/scope-resolution/use-shadows-formal1.2-0.good +++ b/test/errors/scope-resolution/use-shadows-formal1.2-0.good @@ -4,12 +4,12 @@ 15 | writeln(a); | ⎺ | - It refers to a symbol found through the 'use' statement here: + It refers to a symbol found through the 'use' of 'M1' here: | 14 | use M1; | ⎺⎺ | - And then through the 'use' statement here: + And then through the 'use' of 'M0' here: | 6 | public use M0 only b as a; | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ diff --git a/test/errors/scope-resolution/use-shadows-formal2.1.good b/test/errors/scope-resolution/use-shadows-formal2.1.good index 8f6f3468c325..2bec2eb601d5 100644 --- a/test/errors/scope-resolution/use-shadows-formal2.1.good +++ b/test/errors/scope-resolution/use-shadows-formal2.1.good @@ -3,7 +3,7 @@ use-shadows-formal2.chpl:2: error: 'b' has multiple definitions use-shadows-formal2.chpl:3: note: redefined here use-shadows-formal2.chpl:14: In function 'foo': use-shadows-formal2.chpl:16: warning: potentially surprising shadowing for 'a' -use-shadows-formal2.chpl:15: note: it refers to a symbol found through the 'use' statement here -use-shadows-formal2.chpl:7: note: and then through the 'use' statement here +use-shadows-formal2.chpl:15: note: it refers to a symbol found through the 'use' of 'M1' here +use-shadows-formal2.chpl:7: note: and then through the 'use' of 'M0' here use-shadows-formal2.chpl:2: note: leading to 'b' defined here use-shadows-formal2.chpl:14: note: but, there is a shadowed symbol 'a' defined here diff --git a/test/errors/scope-resolution/use-shadows-formal2.2.good b/test/errors/scope-resolution/use-shadows-formal2.2.good index d2d415596140..3aa551187a35 100644 --- a/test/errors/scope-resolution/use-shadows-formal2.2.good +++ b/test/errors/scope-resolution/use-shadows-formal2.2.good @@ -17,12 +17,12 @@ 16 | writeln(a); | ⎺ | - It refers to a symbol found through the 'use' statement here: + It refers to a symbol found through the 'use' of 'M1' here: | 15 | use M1; | ⎺⎺ | - And then through the 'use' statement here: + And then through the 'use' of 'M0' here: | 7 | public use M0 only b as a; | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ diff --git a/test/modules/deitz/test_module_class_conflict2.good b/test/modules/deitz/test_module_class_conflict2.good index f20bf80e5f02..de005be1afbf 100644 --- a/test/modules/deitz/test_module_class_conflict2.good +++ b/test/modules/deitz/test_module_class_conflict2.good @@ -1,7 +1,7 @@ test_module_class_conflict2.chpl:11: In module 'M1': test_module_class_conflict2.chpl:13: warning: potentially surprising shadowing for 'MC' -test_module_class_conflict2.chpl:12: note: it refers to a symbol found through the 'use' statement here -test_module_class_conflict2.chpl:8: note: and then through the 'use' statement here +test_module_class_conflict2.chpl:12: note: it refers to a symbol found through the 'use' of 'M2' here +test_module_class_conflict2.chpl:8: note: and then through the 'use' of 'MC' here test_module_class_conflict2.chpl:2: note: leading to 'MC' defined here test_module_class_conflict2.chpl:1: note: but, there is a shadowed symbol 'MC' defined here test_module_class_conflict2.chpl:13: error: cannot 'use' symbol 'MC', which is not a module or enum diff --git a/test/modules/deitz/test_module_use4.good b/test/modules/deitz/test_module_use4.good index 77cd51e1bfc6..6c18ea8407cb 100644 --- a/test/modules/deitz/test_module_use4.good +++ b/test/modules/deitz/test_module_use4.good @@ -1,7 +1,7 @@ test_module_use4.chpl:10: In module 'M3': test_module_use4.chpl:12: warning: potentially surprising shadowing for 'M1' -test_module_use4.chpl:11: note: it refers to a symbol found through the 'use' statement here -test_module_use4.chpl:7: note: and then through the 'use' statement here +test_module_use4.chpl:11: note: it refers to a symbol found through the 'use' of 'M2' here +test_module_use4.chpl:7: note: and then through the 'use' of 'M1' here test_module_use4.chpl:2: note: leading to 'M1' defined here test_module_use4.chpl:1: note: but, there is a shadowed symbol 'M1' defined here test_module_use4.chpl:12: error: cannot 'use' symbol 'M1', which is not a module or enum diff --git a/test/modules/diten/moduleShadowFormal.good b/test/modules/diten/moduleShadowFormal.good index c7473f4c90fc..97fe0969fd1b 100644 --- a/test/modules/diten/moduleShadowFormal.good +++ b/test/modules/diten/moduleShadowFormal.good @@ -1,6 +1,6 @@ moduleShadowFormal.chpl:9: In function 'foo': moduleShadowFormal.chpl:11: warning: potentially surprising shadowing for 'a' -moduleShadowFormal.chpl:10: note: it refers to a symbol found through the 'use' statement here +moduleShadowFormal.chpl:10: note: it refers to a symbol found through the 'use' of 'M1' here moduleShadowFormal.chpl:2: note: leading to 'a' defined here moduleShadowFormal.chpl:9: note: but, there is a shadowed symbol 'a' defined here 0 diff --git a/test/modules/diten/test_use_chain_resolution.good b/test/modules/diten/test_use_chain_resolution.good index de2a9e9ded48..5b76e157e258 100644 --- a/test/modules/diten/test_use_chain_resolution.good +++ b/test/modules/diten/test_use_chain_resolution.good @@ -1,8 +1,8 @@ test_use_chain_resolution.chpl:23: In function 'main': test_use_chain_resolution.chpl:25: warning: potentially surprising shadowing for 'aaa' -test_use_chain_resolution.chpl:24: note: it refers to a symbol found through the 'use' statement here -test_use_chain_resolution.chpl:10: note: and then through the 'use' statement here -test_use_chain_resolution.chpl:6: note: and then through the 'use' statement here +test_use_chain_resolution.chpl:24: note: it refers to a symbol found through the 'use' of 'M3' here +test_use_chain_resolution.chpl:10: note: and then through the 'use' of 'M2' here +test_use_chain_resolution.chpl:6: note: and then through the 'use' of 'M1' here test_use_chain_resolution.chpl:2: note: leading to 'aaa' defined here test_use_chain_resolution.chpl:22: note: but, there is a shadowed symbol 'aaa' defined here test_use_chain_resolution.chpl:2: error: symbol aaa is multiply defined diff --git a/test/modules/diten/test_use_chain_resolution2.good b/test/modules/diten/test_use_chain_resolution2.good index 4536289f4ed8..7a291ff50023 100644 --- a/test/modules/diten/test_use_chain_resolution2.good +++ b/test/modules/diten/test_use_chain_resolution2.good @@ -1,7 +1,7 @@ test_use_chain_resolution2.chpl:23: In function 'main': test_use_chain_resolution2.chpl:25: warning: potentially surprising shadowing for 'aaa' -test_use_chain_resolution2.chpl:24: note: it refers to a symbol found through the 'use' statement here -test_use_chain_resolution2.chpl:6: note: and then through the 'use' statement here +test_use_chain_resolution2.chpl:24: note: it refers to a symbol found through the 'use' of 'M2' here +test_use_chain_resolution2.chpl:6: note: and then through the 'use' of 'M1' here test_use_chain_resolution2.chpl:2: note: leading to 'aaa' defined here test_use_chain_resolution2.chpl:22: note: but, there is a shadowed symbol 'aaa' defined here test_use_chain_resolution2.chpl:2: error: symbol aaa is multiply defined diff --git a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good b/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good index 8241d7ae3c73..77650cadfc76 100644 --- a/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good +++ b/test/modules/figueroa/DuplicateConfigVars/DuplicateConfigVars.good @@ -1,22 +1,22 @@ DuplicateConfigVars.chpl:4: In function 'main': DuplicateConfigVars.chpl:6: warning: potentially surprising shadowing for 'arraySize' -DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' of 'RandomNumber' here RandomNumber.chpl:18: note: leading to 'arraySize' defined here DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here DuplicateConfigVars.chpl:9: warning: potentially surprising shadowing for 'arraySize' -DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' of 'RandomNumber' here RandomNumber.chpl:18: note: leading to 'arraySize' defined here DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here DuplicateConfigVars.chpl:12: warning: potentially surprising shadowing for 'arraySize' -DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' of 'RandomNumber' here RandomNumber.chpl:18: note: leading to 'arraySize' defined here DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here DuplicateConfigVars.chpl:16: warning: potentially surprising shadowing for 'arraySize' -DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' of 'RandomNumber' here RandomNumber.chpl:18: note: leading to 'arraySize' defined here DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here DuplicateConfigVars.chpl:19: warning: potentially surprising shadowing for 'arraySize' -DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' statement here +DuplicateConfigVars.chpl:5: note: it refers to a symbol found through the 'use' of 'RandomNumber' here RandomNumber.chpl:18: note: leading to 'arraySize' defined here DuplicateConfigVars.chpl:2: note: but, there is a shadowed symbol 'arraySize' defined here Generated points: diff --git a/test/modules/noakes/mod-init-fails.good b/test/modules/noakes/mod-init-fails.good index df290439294d..21309cf4df93 100644 --- a/test/modules/noakes/mod-init-fails.good +++ b/test/modules/noakes/mod-init-fails.good @@ -1,11 +1,11 @@ mod-init-fails.chpl:1: In module 'Main': mod-init-fails.chpl:3: warning: potentially surprising shadowing for 'M2' -mod-init-fails.chpl:2: note: it refers to a symbol found through the 'use' statement here +mod-init-fails.chpl:2: note: it refers to a symbol found through the 'use' of 'M1' here mod-init-fails.chpl:26: note: leading to 'M2' defined here mod-init-fails.chpl:33: note: but, there is a shadowed symbol 'M2' defined here mod-init-fails.chpl:61: In module 'M4': mod-init-fails.chpl:63: warning: potentially surprising shadowing for 'M2' -mod-init-fails.chpl:62: note: it refers to a symbol found through the 'use' statement here +mod-init-fails.chpl:62: note: it refers to a symbol found through the 'use' of 'M1' here mod-init-fails.chpl:26: note: leading to 'M2' defined here mod-init-fails.chpl:33: note: but, there is a shadowed symbol 'M2' defined here 1.1: Module M1.M2 diff --git a/test/modules/noakes/mod-init-works.good b/test/modules/noakes/mod-init-works.good index 8a17fc712435..3d3271c6fd34 100644 --- a/test/modules/noakes/mod-init-works.good +++ b/test/modules/noakes/mod-init-works.good @@ -1,6 +1,6 @@ mod-init-works.chpl:61: In module 'M4': mod-init-works.chpl:63: warning: potentially surprising shadowing for 'M2' -mod-init-works.chpl:62: note: it refers to a symbol found through the 'use' statement here +mod-init-works.chpl:62: note: it refers to a symbol found through the 'use' of 'M1' here mod-init-works.chpl:26: note: leading to 'M2' defined here mod-init-works.chpl:33: note: but, there is a shadowed symbol 'M2' defined here 1.1: Module M1.M2 diff --git a/test/modules/shadowing/issue-19167-0.good b/test/modules/shadowing/issue-19167-0.good index 645dfe68bbb4..db8f39cc8d21 100644 --- a/test/modules/shadowing/issue-19167-0.good +++ b/test/modules/shadowing/issue-19167-0.good @@ -1,6 +1,6 @@ issue-19167-0.chpl:10: In function 'main': issue-19167-0.chpl:12: warning: potentially surprising shadowing for 'X' -issue-19167-0.chpl:11: note: it refers to a symbol found through the 'use' statement here +issue-19167-0.chpl:11: note: it refers to a symbol found through the 'use' of 'M' here issue-19167-0.chpl:2: note: leading to 'X' defined here issue-19167-0.chpl:7: note: but, there is a shadowed symbol 'X' defined here 0 diff --git a/test/modules/shadowing/issue-19167-1-x.good b/test/modules/shadowing/issue-19167-1-x.good index bed3fde879bf..f4a2e6bbb038 100644 --- a/test/modules/shadowing/issue-19167-1-x.good +++ b/test/modules/shadowing/issue-19167-1-x.good @@ -1,5 +1,5 @@ issue-19167-1-x.chpl:8: error: 'x' has multiple definitions in this scope -issue-19167-1-x.chpl:9: note: it was first defined through the 'use' statement here +issue-19167-1-x.chpl:9: note: it was first defined through the 'use' of 'A' here issue-19167-1-x.chpl:2: note: leading to the definition here -issue-19167-1-x.chpl:10: note: redefined through the 'use' statement here +issue-19167-1-x.chpl:10: note: redefined through the 'use' of 'B' here issue-19167-1-x.chpl:5: note: leading to the definition here diff --git a/test/modules/shadowing/issue-19167-2-x.good b/test/modules/shadowing/issue-19167-2-x.good index 2853fccd7bc0..f4165cfb6395 100644 --- a/test/modules/shadowing/issue-19167-2-x.good +++ b/test/modules/shadowing/issue-19167-2-x.good @@ -1,6 +1,6 @@ issue-19167-2-x.chpl:12: error: 'x' has multiple definitions in this scope -issue-19167-2-x.chpl:13: note: it was first defined through the 'use' statement here +issue-19167-2-x.chpl:13: note: it was first defined through the 'use' of 'A' here issue-19167-2-x.chpl:2: note: leading to the definition here -issue-19167-2-x.chpl:14: note: redefined through the 'use' statement here -issue-19167-2-x.chpl:9: note: and then through the 'use' statement here +issue-19167-2-x.chpl:14: note: redefined through the 'use' of 'UseB' here +issue-19167-2-x.chpl:9: note: and then through the 'use' of 'B' here issue-19167-2-x.chpl:5: note: leading to the definition here diff --git a/test/modules/shadowing/issue-19167-3-x.good b/test/modules/shadowing/issue-19167-3-x.good index 9aff1b877823..53881e24f3c5 100644 --- a/test/modules/shadowing/issue-19167-3-x.good +++ b/test/modules/shadowing/issue-19167-3-x.good @@ -1,4 +1,4 @@ issue-19167-3-x.chpl:5: In module 'CUseA': issue-19167-3-x.chpl:7: error: 'x' has multiple definitions -issue-19167-3-x.chpl:6: note: redefined through the 'use' statement here +issue-19167-3-x.chpl:6: note: redefined through the 'use' of 'A' here issue-19167-3-x.chpl:2: note: leading to the definition here diff --git a/test/modules/shadowing/issue-19167-4-x.good b/test/modules/shadowing/issue-19167-4-x.good index 3716908faf51..38c012e252c0 100644 --- a/test/modules/shadowing/issue-19167-4-x.good +++ b/test/modules/shadowing/issue-19167-4-x.good @@ -1,10 +1,10 @@ issue-19167-4-x.chpl:5: In module 'CUseA': issue-19167-4-x.chpl:7: error: 'x' has multiple definitions -issue-19167-4-x.chpl:6: note: redefined through the 'use' statement here +issue-19167-4-x.chpl:6: note: redefined through the 'use' of 'A' here issue-19167-4-x.chpl:2: note: leading to the definition here issue-19167-4-x.chpl:10: error: 'x' has multiple definitions in this scope -issue-19167-4-x.chpl:11: note: it was first defined through the 'use' statement here +issue-19167-4-x.chpl:11: note: it was first defined through the 'use' of 'CUseA' here issue-19167-4-x.chpl:7: note: leading to the definition here -issue-19167-4-x.chpl:11: note: redefined through the 'use' statement here -issue-19167-4-x.chpl:6: note: and then through the 'use' statement here +issue-19167-4-x.chpl:11: note: redefined through the 'use' of 'CUseA' here +issue-19167-4-x.chpl:6: note: and then through the 'use' of 'A' here issue-19167-4-x.chpl:2: note: leading to the definition here diff --git a/test/modules/shadowing/issue-19167-5-x.good b/test/modules/shadowing/issue-19167-5-x.good index ad1f3c37e403..b90be4b20d83 100644 --- a/test/modules/shadowing/issue-19167-5-x.good +++ b/test/modules/shadowing/issue-19167-5-x.good @@ -1,10 +1,10 @@ issue-19167-5-x.chpl:5: In module 'CUseA': issue-19167-5-x.chpl:7: error: 'x' has multiple definitions -issue-19167-5-x.chpl:6: note: redefined through the 'use' statement here +issue-19167-5-x.chpl:6: note: redefined through the 'use' of 'A' here issue-19167-5-x.chpl:2: note: leading to the definition here issue-19167-5-x.chpl:10: error: 'x' has multiple definitions in this scope -issue-19167-5-x.chpl:11: note: it was first defined through the 'use' statement here +issue-19167-5-x.chpl:11: note: it was first defined through the 'use' of 'CUseA' here issue-19167-5-x.chpl:7: note: leading to the definition here -issue-19167-5-x.chpl:11: note: redefined through the 'use' statement here -issue-19167-5-x.chpl:6: note: and then through the 'use' statement here +issue-19167-5-x.chpl:11: note: redefined through the 'use' of 'CUseA' here +issue-19167-5-x.chpl:6: note: and then through the 'use' of 'A' here issue-19167-5-x.chpl:2: note: leading to the definition here diff --git a/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good index 5d8651a1a35e..03ec77c9f488 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/hijacking-example.good @@ -1,6 +1,6 @@ hijacking-example.chpl:19: In function 'main': hijacking-example.chpl:21: warning: potentially surprising shadowing for 'N' -hijacking-example.chpl:20: note: it refers to a symbol found through the 'use' statement here +hijacking-example.chpl:20: note: it refers to a symbol found through the 'use' of 'M' here hijacking-example.chpl:5: note: leading to 'N' defined here hijacking-example.chpl:12: note: but, there is a shadowed symbol 'N' defined here Hijacked! diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good index 2b2668019a1b..9c6d6fe55012 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-private-bring-samename.good @@ -1,7 +1,7 @@ public-private-bring-samename.chpl:13: In function 'main': public-private-bring-samename.chpl:14: warning: potentially surprising shadowing for 'x' -public-private-bring-samename.chpl:10: note: it refers to a symbol found through the 'use' statement here +public-private-bring-samename.chpl:10: note: it refers to a symbol found through the 'use' of 'M' here public-private-bring-samename.chpl:2: note: leading to 'x' defined here -public-private-bring-samename.chpl:11: note: but, there is a shadowed symbol found through the 'use' statement here +public-private-bring-samename.chpl:11: note: but, there is a shadowed symbol found through the 'use' of 'N' here public-private-bring-samename.chpl:6: note: leading to 'x' defined here 1 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good index ee6ef7f8fd0a..6b3f44d08f57 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/public-use-vs-outer.good @@ -1,6 +1,6 @@ public-use-vs-outer.chpl:7: In function 'main': public-use-vs-outer.chpl:9: warning: potentially surprising shadowing for 'x' -public-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' statement here +public-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' of 'M' here public-use-vs-outer.chpl:2: note: leading to 'x' defined here public-use-vs-outer.chpl:6: note: but, there is a shadowed symbol 'x' defined here 42 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good index 98bd6235ae41..c360cb86ed6a 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-submodule.good @@ -1,10 +1,10 @@ submodule-in-used-vs-submodule.chpl:12: In function 'main': submodule-in-used-vs-submodule.chpl:14: warning: potentially surprising shadowing for 'N' -submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here submodule-in-used-vs-submodule.chpl:3: note: leading to 'N' defined here submodule-in-used-vs-submodule.chpl:8: note: but, there is a shadowed symbol 'N' defined here submodule-in-used-vs-submodule.chpl:15: warning: potentially surprising shadowing for 'N' -submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-submodule.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here submodule-in-used-vs-submodule.chpl:3: note: leading to 'N' defined here submodule-in-used-vs-submodule.chpl:8: note: but, there is a shadowed symbol 'N' defined here 100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good index 712f77abc0fc..9147e10f7fab 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-1.good @@ -1,7 +1,7 @@ submodule-in-used-vs-toplevel-1.chpl:14: In function 'main': submodule-in-used-vs-toplevel-1.chpl:15: warning: potentially surprising shadowing for 'N' -submodule-in-used-vs-toplevel-1.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-1.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here submodule-in-used-vs-toplevel-1.chpl:2: note: leading to 'N' defined here -submodule-in-used-vs-toplevel-1.chpl:12: note: but, there is a shadowed symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-1.chpl:12: note: but, there is a shadowed symbol found through the 'use' of 'N' here submodule-in-used-vs-toplevel-1.chpl:7: note: leading to 'N' defined here 100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good index 9eccc2f1f854..18ece9c8b8b4 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-2.good @@ -1,6 +1,6 @@ submodule-in-used-vs-toplevel-2.chpl:11: In module 'Application': submodule-in-used-vs-toplevel-2.chpl:13: warning: potentially surprising shadowing for 'N' -submodule-in-used-vs-toplevel-2.chpl:12: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-2.chpl:12: note: it refers to a symbol found through the 'use' of 'M' here submodule-in-used-vs-toplevel-2.chpl:2: note: leading to 'N' defined here submodule-in-used-vs-toplevel-2.chpl:7: note: but, there is a shadowed symbol 'N' defined here 100 diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good index a62f558461f8..24a550729a60 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-3.good @@ -1,5 +1,5 @@ submodule-in-used-vs-toplevel-3.chpl:12: In function 'main': submodule-in-used-vs-toplevel-3.chpl:14: warning: potentially surprising shadowing for 'N' -submodule-in-used-vs-toplevel-3.chpl:13: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-3.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here submodule-in-used-vs-toplevel-3.chpl:2: note: leading to 'N' defined here submodule-in-used-vs-toplevel-3.chpl:7: note: but, there is a shadowed symbol 'N' defined here diff --git a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good index 7d28d1a64f60..ce66bfd9a3c2 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/submodule-in-used-vs-toplevel-in-file.good @@ -1,6 +1,6 @@ submodule-in-used-vs-toplevel-in-file.chpl:7: In function 'main': submodule-in-used-vs-toplevel-in-file.chpl:9: warning: potentially surprising shadowing for 'MM' -submodule-in-used-vs-toplevel-in-file.chpl:8: note: it refers to a symbol found through the 'use' statement here +submodule-in-used-vs-toplevel-in-file.chpl:8: note: it refers to a symbol found through the 'use' of 'N' here submodule-in-used-vs-toplevel-in-file.chpl:2: note: leading to 'MM' defined here MM.chpl:1: note: but, there is a shadowed symbol 'MM' defined here 0 diff --git a/test/modules/shadowing/var-shadows-private-import.good b/test/modules/shadowing/var-shadows-private-import.good index 934629a31a9b..5deefb3b80fb 100644 --- a/test/modules/shadowing/var-shadows-private-import.good +++ b/test/modules/shadowing/var-shadows-private-import.good @@ -1,4 +1,4 @@ var-shadows-private-import.chpl:6: In module 'N': var-shadows-private-import.chpl:8: error: 'x' has multiple definitions -var-shadows-private-import.chpl:7: note: redefined through the 'import' statement here +var-shadows-private-import.chpl:7: note: redefined through the 'import' of 'M' here var-shadows-private-import.chpl:3: note: leading to the definition here diff --git a/test/modules/shadowing/var-shadows-public-import.good b/test/modules/shadowing/var-shadows-public-import.good index 999376d9de79..6a23cee075a8 100644 --- a/test/modules/shadowing/var-shadows-public-import.good +++ b/test/modules/shadowing/var-shadows-public-import.good @@ -1,4 +1,4 @@ var-shadows-public-import.chpl:6: In module 'N': var-shadows-public-import.chpl:8: error: 'x' has multiple definitions -var-shadows-public-import.chpl:7: note: redefined through the 'import' statement here +var-shadows-public-import.chpl:7: note: redefined through the 'import' of 'M' here var-shadows-public-import.chpl:3: note: leading to the definition here diff --git a/test/modules/shadowing/var-shadows-public-use.good b/test/modules/shadowing/var-shadows-public-use.good index 70c7150b1ac0..72ff48496541 100644 --- a/test/modules/shadowing/var-shadows-public-use.good +++ b/test/modules/shadowing/var-shadows-public-use.good @@ -1,4 +1,4 @@ var-shadows-public-use.chpl:5: In module 'N': var-shadows-public-use.chpl:7: error: 'x' has multiple definitions -var-shadows-public-use.chpl:6: note: redefined through the 'use' statement here +var-shadows-public-use.chpl:6: note: redefined through the 'use' of 'M' here var-shadows-public-use.chpl:2: note: leading to the definition here diff --git a/test/modules/use/topLevel/modNameVsSecondUse.good b/test/modules/use/topLevel/modNameVsSecondUse.good index dd4f973e56a4..e5cb16b20fd8 100644 --- a/test/modules/use/topLevel/modNameVsSecondUse.good +++ b/test/modules/use/topLevel/modNameVsSecondUse.good @@ -1,7 +1,7 @@ modNameVsSecondUse.chpl:13: In function 'main': modNameVsSecondUse.chpl:16: warning: potentially surprising shadowing for 'M' -modNameVsSecondUse.chpl:15: note: it refers to a symbol found through the 'use' statement here +modNameVsSecondUse.chpl:15: note: it refers to a symbol found through the 'use' of 'N' here modNameVsSecondUse.chpl:9: note: leading to 'M' defined here -modNameVsSecondUse.chpl:14: note: but, there is a shadowed symbol found through the 'use' statement here +modNameVsSecondUse.chpl:14: note: but, there is a shadowed symbol found through the 'use' of 'M' here modNameVsSecondUse.chpl:1: note: leading to 'M' defined here 42 diff --git a/test/modules/use/topLevel/subVsTop.good b/test/modules/use/topLevel/subVsTop.good index fc6d71fe324c..312d85a3529a 100644 --- a/test/modules/use/topLevel/subVsTop.good +++ b/test/modules/use/topLevel/subVsTop.good @@ -1,7 +1,7 @@ subVsTop.chpl:1: In module 'OuterModule': subVsTop.chpl:15: warning: potentially surprising shadowing for 'N' -subVsTop.chpl:14: note: it refers to a symbol found through the 'use' statement here +subVsTop.chpl:14: note: it refers to a symbol found through the 'use' of 'M' here subVsTop.chpl:3: note: leading to 'N' defined here -subVsTop.chpl:13: note: but, there is a shadowed symbol found through the 'use' statement here +subVsTop.chpl:13: note: but, there is a shadowed symbol found through the 'use' of 'N' here subVsTop.chpl:8: note: leading to 'N' defined here M diff --git a/test/modules/use/topLevel/subVsTop1a.good b/test/modules/use/topLevel/subVsTop1a.good index 208636d55942..e0bc21e8aafc 100644 --- a/test/modules/use/topLevel/subVsTop1a.good +++ b/test/modules/use/topLevel/subVsTop1a.good @@ -1,10 +1,10 @@ subVsTop1a.chpl:1: In module 'OuterModule': subVsTop1a.chpl:14: warning: potentially surprising shadowing for 'N' -subVsTop1a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop1a.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here subVsTop1a.chpl:3: note: leading to 'N' defined here subVsTop1a.chpl:8: note: but, there is a shadowed symbol 'N' defined here subVsTop1a.chpl:15: warning: potentially surprising shadowing for 'N' -subVsTop1a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop1a.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here subVsTop1a.chpl:3: note: leading to 'N' defined here subVsTop1a.chpl:8: note: but, there is a shadowed symbol 'N' defined here M diff --git a/test/modules/use/topLevel/subVsTop2.good b/test/modules/use/topLevel/subVsTop2.good index c6c8a93c8696..9ec76db3dad9 100644 --- a/test/modules/use/topLevel/subVsTop2.good +++ b/test/modules/use/topLevel/subVsTop2.good @@ -1,7 +1,7 @@ subVsTop2.chpl:1: In module 'OuterModule': subVsTop2.chpl:15: warning: potentially surprising shadowing for 'N' -subVsTop2.chpl:14: note: it refers to a symbol found through the 'use' statement here +subVsTop2.chpl:14: note: it refers to a symbol found through the 'use' of 'M' here subVsTop2.chpl:3: note: leading to 'N' defined here -subVsTop2.chpl:13: note: but, there is a shadowed symbol found through the 'use' statement here +subVsTop2.chpl:13: note: but, there is a shadowed symbol found through the 'use' of 'N' here subVsTop2.chpl:8: note: leading to 'N' defined here 100 diff --git a/test/modules/use/topLevel/subVsTop2a.good b/test/modules/use/topLevel/subVsTop2a.good index 18bffef22419..eee82cd65330 100644 --- a/test/modules/use/topLevel/subVsTop2a.good +++ b/test/modules/use/topLevel/subVsTop2a.good @@ -1,10 +1,10 @@ subVsTop2a.chpl:1: In module 'OuterModule': subVsTop2a.chpl:14: warning: potentially surprising shadowing for 'N' -subVsTop2a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop2a.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here subVsTop2a.chpl:3: note: leading to 'N' defined here subVsTop2a.chpl:8: note: but, there is a shadowed symbol 'N' defined here subVsTop2a.chpl:15: warning: potentially surprising shadowing for 'N' -subVsTop2a.chpl:13: note: it refers to a symbol found through the 'use' statement here +subVsTop2a.chpl:13: note: it refers to a symbol found through the 'use' of 'M' here subVsTop2a.chpl:3: note: leading to 'N' defined here subVsTop2a.chpl:8: note: but, there is a shadowed symbol 'N' defined here 100 diff --git a/test/release/examples/primers/modules.good b/test/release/examples/primers/modules.good index c217d1248d6f..8971048ec872 100644 --- a/test/release/examples/primers/modules.good +++ b/test/release/examples/primers/modules.good @@ -1,6 +1,6 @@ modules.chpl:126: In function 'main': modules.chpl:306: warning: potentially surprising shadowing for 'bar' -modules.chpl:305: note: it refers to a symbol found through the 'use' statement here +modules.chpl:305: note: it refers to a symbol found through the 'use' of 'ModToUse' here modules.chpl:37: note: leading to 'bar' defined here modules.chpl:302: note: but, there is a shadowed symbol 'bar' defined here Start of reverse file-order output diff --git a/test/types/enum/lydia/use/exceptList.good b/test/types/enum/lydia/use/exceptList.good index 26e1fffe9d19..45ccb3ad104a 100644 --- a/test/types/enum/lydia/use/exceptList.good +++ b/test/types/enum/lydia/use/exceptList.good @@ -1,6 +1,6 @@ exceptList.chpl:11: In function 'main': exceptList.chpl:14: warning: potentially surprising shadowing for 'paul' -exceptList.chpl:12: note: it refers to a symbol found through the 'use' statement here +exceptList.chpl:12: note: it refers to a symbol found through the 'use' of 'beatles' here exceptList.chpl:4: note: leading to 'paul' defined here exceptList.chpl:6: note: but, there is a shadowed symbol 'paul' defined here paul diff --git a/test/types/enum/lydia/use/onlyList.good b/test/types/enum/lydia/use/onlyList.good index ca0a867a8d51..374b70593cc7 100644 --- a/test/types/enum/lydia/use/onlyList.good +++ b/test/types/enum/lydia/use/onlyList.good @@ -1,7 +1,2 @@ -onlyList.chpl:11: In function 'main': -onlyList.chpl:14: warning: potentially surprising shadowing for 'paul' -onlyList.chpl:12: note: it refers to a symbol found through the 'use' statement here -onlyList.chpl:4: note: leading to 'paul' defined here -onlyList.chpl:6: note: but, there is a shadowed symbol 'paul' defined here paul clooney diff --git a/test/types/enum/lydia/use/shadowsOuter.good b/test/types/enum/lydia/use/shadowsOuter.good index 3e07e0df3b1b..b2766a67193b 100644 --- a/test/types/enum/lydia/use/shadowsOuter.good +++ b/test/types/enum/lydia/use/shadowsOuter.good @@ -1,10 +1,10 @@ shadowsOuter.chpl:12: In function 'main': shadowsOuter.chpl:15: warning: potentially surprising shadowing for 'paul' -shadowsOuter.chpl:13: note: it refers to a symbol found through the 'use' statement here +shadowsOuter.chpl:13: note: it refers to a symbol found through the 'use' of 'beatles' here shadowsOuter.chpl:5: note: leading to 'paul' defined here shadowsOuter.chpl:7: note: but, there is a shadowed symbol 'paul' defined here shadowsOuter.chpl:16: warning: potentially surprising shadowing for 'george' -shadowsOuter.chpl:13: note: it refers to a symbol found through the 'use' statement here +shadowsOuter.chpl:13: note: it refers to a symbol found through the 'use' of 'beatles' here shadowsOuter.chpl:5: note: leading to 'george' defined here shadowsOuter.chpl:8: note: but, there is a shadowed symbol 'george' defined here paul diff --git a/test/visibility/import/edgeCases/anotherMultipleDef2.good b/test/visibility/import/edgeCases/anotherMultipleDef2.good index 16411c8ec5d7..700b40932235 100644 --- a/test/visibility/import/edgeCases/anotherMultipleDef2.good +++ b/test/visibility/import/edgeCases/anotherMultipleDef2.good @@ -1,5 +1,5 @@ anotherMultipleDef2.chpl:14: error: 'A' has multiple definitions in this scope -anotherMultipleDef2.chpl:15: note: it was first defined through the 'import' statement here +anotherMultipleDef2.chpl:15: note: it was first defined through the 'import' of 'A' here anotherMultipleDef2.chpl:1: note: leading to the definition here -anotherMultipleDef2.chpl:16: note: redefined through the 'use' statement here +anotherMultipleDef2.chpl:16: note: redefined through the 'use' of 'B' here anotherMultipleDef2.chpl:7: note: leading to the definition here diff --git a/test/visibility/import/edgeCases/multipleDef2.good b/test/visibility/import/edgeCases/multipleDef2.good index fb1bc7be602c..80df9074f899 100644 --- a/test/visibility/import/edgeCases/multipleDef2.good +++ b/test/visibility/import/edgeCases/multipleDef2.good @@ -1,5 +1,5 @@ multipleDef2.chpl:7: error: 'x' has multiple definitions in this scope -multipleDef2.chpl:8: note: it was first defined through the 'import' statement here +multipleDef2.chpl:8: note: it was first defined through the 'import' of 'A' here multipleDef2.chpl:2: note: leading to the definition here -multipleDef2.chpl:9: note: redefined through the 'import' statement here +multipleDef2.chpl:9: note: redefined through the 'import' of 'B' here multipleDef2.chpl:5: note: leading to the definition here diff --git a/test/visibility/import/edgeCases/multipleDef3.good b/test/visibility/import/edgeCases/multipleDef3.good index 272f3287ec8c..2155bf1eb5af 100644 --- a/test/visibility/import/edgeCases/multipleDef3.good +++ b/test/visibility/import/edgeCases/multipleDef3.good @@ -1,5 +1,5 @@ multipleDef3.chpl:7: error: 'x' has multiple definitions in this scope -multipleDef3.chpl:8: note: it was first defined through the 'import' statement here +multipleDef3.chpl:8: note: it was first defined through the 'import' of 'A' here multipleDef3.chpl:2: note: leading to the definition here -multipleDef3.chpl:9: note: redefined through the 'import' statement here +multipleDef3.chpl:9: note: redefined through the 'import' of 'B' here multipleDef3.chpl:5: note: leading to the definition here diff --git a/test/visibility/import/rename/same_name_in_mod.good b/test/visibility/import/rename/same_name_in_mod.good index 63d758d6c784..5034164faff1 100644 --- a/test/visibility/import/rename/same_name_in_mod.good +++ b/test/visibility/import/rename/same_name_in_mod.good @@ -1,4 +1,4 @@ same_name_in_mod.chpl:4: In module 'User': same_name_in_mod.chpl:7: error: 'F' has multiple definitions -same_name_in_mod.chpl:5: note: redefined through the 'import' statement here +same_name_in_mod.chpl:5: note: redefined through the 'import' of 'Foo' here same_name_in_mod.chpl:1: note: leading to the definition here diff --git a/test/visibility/import/rename/same_name_in_mod2.good b/test/visibility/import/rename/same_name_in_mod2.good index e536a3355b38..2b1f13c835e5 100644 --- a/test/visibility/import/rename/same_name_in_mod2.good +++ b/test/visibility/import/rename/same_name_in_mod2.good @@ -1,4 +1,4 @@ same_name_in_mod2.chpl:4: In module 'User': same_name_in_mod2.chpl:7: error: 'F' has multiple definitions -same_name_in_mod2.chpl:5: note: redefined through the 'import' statement here +same_name_in_mod2.chpl:5: note: redefined through the 'import' of 'Foo' here same_name_in_mod2.chpl:1: note: leading to the definition here diff --git a/test/visibility/import/submoduleCloser.bad b/test/visibility/import/submoduleCloser.bad index b5c3cb5ba9bd..a12c1284841e 100644 --- a/test/visibility/import/submoduleCloser.bad +++ b/test/visibility/import/submoduleCloser.bad @@ -1,6 +1,6 @@ submoduleCloser.chpl:11: In function 'main': submoduleCloser.chpl:14: warning: potentially surprising shadowing for 'Details' -submoduleCloser.chpl:13: note: it refers to a symbol found through the 'use' statement here +submoduleCloser.chpl:13: note: it refers to a symbol found through the 'use' of 'ExternalLib1' here submoduleCloser.chpl:2: note: leading to 'Details' defined here submoduleCloser.chpl:6: note: but, there is a shadowed symbol 'Details' defined here submoduleCloser.chpl:15: error: cannot find 'do_my_impl' in module 'Details' diff --git a/test/visibility/prefer-explicit-use.good b/test/visibility/prefer-explicit-use.good index f594a9812882..e310b19e52d7 100644 --- a/test/visibility/prefer-explicit-use.good +++ b/test/visibility/prefer-explicit-use.good @@ -1,6 +1,6 @@ prefer-explicit-use.chpl:13: In method 'foo': prefer-explicit-use.chpl:14: warning: potentially surprising shadowing for 'defaultLowBound' -prefer-explicit-use.chpl:8: note: it refers to a symbol found through the 'use' statement here +prefer-explicit-use.chpl:8: note: it refers to a symbol found through the 'use' of 'UseInsteadOfAuto' here prefer-explicit-use.chpl:6: note: leading to 'defaultLowBound' defined here prefer-explicit-use.chpl:14: note: but, there is a shadowed symbol found in the automatically-included modules $CHPL_HOME/modules/internal/ChapelBase.chpl:78: note: leading to 'defaultLowBound' defined here diff --git a/test/visibility/rename/causesShadow.good b/test/visibility/rename/causesShadow.good index 43603cdb30b7..c508d5366f70 100644 --- a/test/visibility/rename/causesShadow.good +++ b/test/visibility/rename/causesShadow.good @@ -1,6 +1 @@ -causesShadow.chpl:8: In function 'main': -causesShadow.chpl:11: warning: potentially surprising shadowing for 'bar' -causesShadow.chpl:9: note: it refers to a symbol found through the 'use' statement here -causesShadow.chpl:2: note: leading to 'baz' defined here -causesShadow.chpl:6: note: but, there is a shadowed symbol 'bar' defined here false diff --git a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good index 3cd63ec02781..5e4fa5f74b92 100644 --- a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good +++ b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod.good @@ -1,8 +1,8 @@ renameSameNameAsInOtherMod.chpl:11: In function 'main': renameSameNameAsInOtherMod.chpl:12: warning: potentially surprising shadowing for 'Bar' -renameSameNameAsInOtherMod.chpl:9: note: it refers to a symbol found through the 'use' statement here +renameSameNameAsInOtherMod.chpl:9: note: it refers to a symbol found through the 'use' of 'Foo2' here renameSameNameAsInOtherMod.chpl:5: note: leading to 'Bar' defined here -renameSameNameAsInOtherMod.chpl:8: note: but, there is a shadowed symbol found through the 'use' statement here +renameSameNameAsInOtherMod.chpl:8: note: but, there is a shadowed symbol found through the 'use' of 'Foo' here renameSameNameAsInOtherMod.chpl:1: note: leading to 'Foo' defined here renameSameNameAsInOtherMod.chpl:12: error: unresolved call 'int(64).x' renameSameNameAsInOtherMod.chpl:12: note: because no functions named x found in scope diff --git a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good index c506c8cfb99a..4d570c20596f 100644 --- a/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good +++ b/test/visibility/rename/renameUsedMod/renameSameNameAsInOtherMod2.good @@ -1,7 +1,7 @@ renameSameNameAsInOtherMod2.chpl:11: In function 'main': renameSameNameAsInOtherMod2.chpl:12: warning: potentially surprising shadowing for 'Bar' -renameSameNameAsInOtherMod2.chpl:9: note: it refers to a symbol found through the 'use' statement here +renameSameNameAsInOtherMod2.chpl:9: note: it refers to a symbol found through the 'use' of 'Foo2' here renameSameNameAsInOtherMod2.chpl:5: note: leading to 'Bar' defined here -renameSameNameAsInOtherMod2.chpl:8: note: but, there is a shadowed symbol found through the 'use' statement here +renameSameNameAsInOtherMod2.chpl:8: note: but, there is a shadowed symbol found through the 'use' of 'Foo' here renameSameNameAsInOtherMod2.chpl:1: note: leading to 'Foo' defined here 0 diff --git a/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good b/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good index 7b9eb181679d..0a829f9c14f0 100644 --- a/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good +++ b/test/visibility/rename/renameUsedMod/renameSameNameConflict3.good @@ -1,6 +1,6 @@ renameSameNameConflict3.chpl:7: In module 'User': renameSameNameConflict3.chpl:11: warning: potentially surprising shadowing for 'L' -renameSameNameConflict3.chpl:8: note: it refers to a symbol found through the 'use' statement here +renameSameNameConflict3.chpl:8: note: it refers to a symbol found through the 'use' of 'LongName' here renameSameNameConflict3.chpl:1: note: leading to 'LongName' defined here renameSameNameConflict3.chpl:4: note: but, there is a shadowed symbol 'L' defined here 0 From 7774e04aad0d596a476fa777883db1a85f2d79c0 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 3 Oct 2023 11:07:06 -0400 Subject: [PATCH 32/35] Update one more .good for warning wording change --- Signed-off-by: Michael Ferguson --- .../unexpected-shadowing-warning/private-use-vs-outer.good | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good index 5d02f87f20c4..5dd92de75d30 100644 --- a/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good +++ b/test/modules/shadowing/unexpected-shadowing-warning/private-use-vs-outer.good @@ -1,6 +1,6 @@ private-use-vs-outer.chpl:7: In function 'main': private-use-vs-outer.chpl:9: warning: potentially surprising shadowing for 'x' -private-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' statement here +private-use-vs-outer.chpl:8: note: it refers to a symbol found through the 'use' of 'M' here private-use-vs-outer.chpl:2: note: leading to 'x' defined here private-use-vs-outer.chpl:6: note: but, there is a shadowed symbol 'x' defined here 42 From aae7a826f77d4026ed9ca49f7fcc40233dc5d550 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 5 Oct 2023 09:54:36 -0400 Subject: [PATCH 33/35] Un-future submoduleCloser --- Signed-off-by: Michael Ferguson --- test/visibility/import/submoduleCloser.bad | 6 ------ test/visibility/import/submoduleCloser.future | 2 -- test/visibility/import/submoduleCloser.good | 8 ++++++-- 3 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 test/visibility/import/submoduleCloser.bad delete mode 100644 test/visibility/import/submoduleCloser.future diff --git a/test/visibility/import/submoduleCloser.bad b/test/visibility/import/submoduleCloser.bad deleted file mode 100644 index a12c1284841e..000000000000 --- a/test/visibility/import/submoduleCloser.bad +++ /dev/null @@ -1,6 +0,0 @@ -submoduleCloser.chpl:11: In function 'main': -submoduleCloser.chpl:14: warning: potentially surprising shadowing for 'Details' -submoduleCloser.chpl:13: note: it refers to a symbol found through the 'use' of 'ExternalLib1' here -submoduleCloser.chpl:2: note: leading to 'Details' defined here -submoduleCloser.chpl:6: note: but, there is a shadowed symbol 'Details' defined here -submoduleCloser.chpl:15: error: cannot find 'do_my_impl' in module 'Details' diff --git a/test/visibility/import/submoduleCloser.future b/test/visibility/import/submoduleCloser.future deleted file mode 100644 index bc9d2c37ff16..000000000000 --- a/test/visibility/import/submoduleCloser.future +++ /dev/null @@ -1,2 +0,0 @@ -semantic: should top level modules be equally visible for imports as submodules? -#19782 diff --git a/test/visibility/import/submoduleCloser.good b/test/visibility/import/submoduleCloser.good index e6e2a516bf6d..a12c1284841e 100644 --- a/test/visibility/import/submoduleCloser.good +++ b/test/visibility/import/submoduleCloser.good @@ -1,2 +1,6 @@ -whatev -whatev +submoduleCloser.chpl:11: In function 'main': +submoduleCloser.chpl:14: warning: potentially surprising shadowing for 'Details' +submoduleCloser.chpl:13: note: it refers to a symbol found through the 'use' of 'ExternalLib1' here +submoduleCloser.chpl:2: note: leading to 'Details' defined here +submoduleCloser.chpl:6: note: but, there is a shadowed symbol 'Details' defined here +submoduleCloser.chpl:15: error: cannot find 'do_my_impl' in module 'Details' From b1fab285742ff25d782593af2996c3421b0f218e Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 5 Oct 2023 14:44:38 -0400 Subject: [PATCH 34/35] Adjust name of variable for consistency --- Signed-off-by: Michael Ferguson --- frontend/lib/resolution/scope-queries.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/lib/resolution/scope-queries.cpp b/frontend/lib/resolution/scope-queries.cpp index b9ceac4a848d..d5ac59e319f4 100644 --- a/frontend/lib/resolution/scope-queries.cpp +++ b/frontend/lib/resolution/scope-queries.cpp @@ -1167,11 +1167,11 @@ bool LookupHelper::doLookupInScope(const Scope* scope, if (onlyInnermost && got) return true; } - std::unordered_set* ignoreClausesForShadowScope2 = nullptr; + std::unordered_set* ignoreClausesForShadowScopeTwo = nullptr; if (checkMoreForWarning) { // ignore 'use M' bringing in M and hiding the module name, // for the purpose of the warning. - ignoreClausesForShadowScope2 = &foundInShadowScopeOneClauses; + ignoreClausesForShadowScopeTwo = &foundInShadowScopeOneClauses; } // now check shadow scope 2 (only relevant for 'private use') @@ -1182,7 +1182,7 @@ bool LookupHelper::doLookupInScope(const Scope* scope, VisibilitySymbols::SHADOW_SCOPE_TWO, /* foundInAllContents */ nullptr, /* foundInClauses */ nullptr, - ignoreClausesForShadowScope2); + ignoreClausesForShadowScopeTwo); if (got && canCheckMoreForWarning && !checkMoreForWarning) { checkMoreForWarning = true; onlyInnermost = false; From 5bbf06c8d38fc9b7243dc75c885c068316185165 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 5 Oct 2023 15:31:20 -0400 Subject: [PATCH 35/35] Add prediff to avoid sensitivity to module line numbers --- Signed-off-by: Michael Ferguson --- test/visibility/prefer-explicit-use.good | 2 +- test/visibility/prefer-explicit-use.prediff | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 120000 test/visibility/prefer-explicit-use.prediff diff --git a/test/visibility/prefer-explicit-use.good b/test/visibility/prefer-explicit-use.good index e310b19e52d7..744975819f98 100644 --- a/test/visibility/prefer-explicit-use.good +++ b/test/visibility/prefer-explicit-use.good @@ -3,5 +3,5 @@ prefer-explicit-use.chpl:14: warning: potentially surprising shadowing for 'defa prefer-explicit-use.chpl:8: note: it refers to a symbol found through the 'use' of 'UseInsteadOfAuto' here prefer-explicit-use.chpl:6: note: leading to 'defaultLowBound' defined here prefer-explicit-use.chpl:14: note: but, there is a shadowed symbol found in the automatically-included modules -$CHPL_HOME/modules/internal/ChapelBase.chpl:78: note: leading to 'defaultLowBound' defined here +$CHPL_HOME/modules/internal/ChapelBase.chpl:nnnn: note: leading to 'defaultLowBound' defined here string diff --git a/test/visibility/prefer-explicit-use.prediff b/test/visibility/prefer-explicit-use.prediff new file mode 120000 index 000000000000..9a012efddf13 --- /dev/null +++ b/test/visibility/prefer-explicit-use.prediff @@ -0,0 +1 @@ +../../util/test/prediff-obscure-module-linenos \ No newline at end of file