Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify use/import shadowing #19306

Merged
merged 96 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
bb26de1
Ambiguity error for module defining sym with same name
mppf Feb 18, 2022
60e8b73
Only private use has shadow scope
mppf Feb 18, 2022
be01731
Move new tests to modules/shadowing
mppf Feb 18, 2022
095a898
Make isMoreVisible in disambiguation consistent
mppf Feb 18, 2022
4aa6966
Partial work
mppf Feb 18, 2022
dc9d125
Tidy up new tests
mppf Feb 23, 2022
e907b2d
Fix test issue-19167-3-x
mppf Feb 23, 2022
8f853a0
Adjust modules primer
mppf Feb 23, 2022
cc7d1f9
Allow private use to have 2 shadow scopes
mppf Feb 23, 2022
291d2ce
Fix test_resolve_best_shadowed2 for different shadowing
mppf Feb 24, 2022
c604074
Fix apparently inadverdent use of Random
mppf Feb 24, 2022
8c994d9
Use the POI scope to start isMoreVisible
mppf Feb 24, 2022
37d9a23
Add test from issue #19198
mppf Feb 24, 2022
551d0fa
Update some module scoping tests
mppf Feb 24, 2022
f942a9a
Use private use rather than public use
mppf Feb 24, 2022
8a60461
Use 'pe' rather than 'e' to avoid conflicts with Math.e
mppf Feb 24, 2022
d8e3e35
Rename module with same name as class
mppf Feb 24, 2022
f06629a
Update a spec test for new behavior
mppf Feb 24, 2022
39127a3
Avoid conflict with Math.e by moving use
mppf Feb 24, 2022
cc1afb3
Update test for back to 2 shadow scopes for private use
mppf Feb 24, 2022
8c774b8
Update breakList.good for new behavior
mppf Feb 24, 2022
f628a0e
Fix except handling
mppf Feb 24, 2022
6b990c1
Check in nested public imports & track publicOnly
mppf Feb 24, 2022
4c3278e
Use ee instead of e to avoid Math.e
mppf Feb 24, 2022
4a8ddfe
Adjust anotherMultipleDef and add a variant
mppf Feb 24, 2022
b1dbbb2
update tests for ambiguity due to no shadow import
mppf Feb 24, 2022
30e30d4
Adjust for no shadow public use
mppf Feb 24, 2022
c6287ac
Fix rename + recursion check
mppf Feb 24, 2022
60b2e84
Fix private module check
mppf Feb 24, 2022
5ab2235
Fix TestSorted future
mppf Feb 25, 2022
6e73790
Adjust a future's .good file
mppf Feb 25, 2022
d1b8236
Use qualified naming to avoid std module Types
mppf Feb 25, 2022
e04ae58
Adjust tests to avoid #19303
mppf Feb 25, 2022
cb1baa6
Change deepUseWouldConflict.good file instead of test
mppf Mar 1, 2022
6703dbf
Update weirdEnumHiding to show private use
mppf Mar 1, 2022
5f47311
Keep public use but rename checkFoo functions
mppf Mar 1, 2022
8ea910e
Add variant that calls mCallFunc
mppf Mar 4, 2022
495dec3
Give the two x variables different values
mppf Mar 4, 2022
bb87175
Continue with module counts / class count but don't public use
mppf Mar 7, 2022
327b59f
Adjust which is code clone to preserve history
mppf Mar 7, 2022
9023947
Public use doesn't bring in module name
mppf Mar 7, 2022
7c60985
Add import Path to MasonPublish.
mppf Mar 7, 2022
5f71c59
Un-future now passing future
mppf Mar 8, 2022
ed89198
Allow 'public use Foo as F' to bring in F
mppf Mar 8, 2022
498c460
Add variant of test to do 'public use Foo as Foo'
mppf Mar 8, 2022
a237c58
Update importAndImportFromUse.good and add clone
mppf Mar 8, 2022
bdd5287
Adjust multipleUnqualified
mppf Mar 8, 2022
fdff165
Adjust tests in visibility/import to have public use
mppf Mar 8, 2022
5915aba
Use 'use A as A' in this directory to keep tests as they were
mppf Mar 8, 2022
78ab7a4
Revert "Adjust tests in visibility/import to have public use"
mppf Mar 8, 2022
38f5ca6
Update .good files with errors
mppf Mar 8, 2022
b5d224a
Adjust onlyNothingField.chpl
mppf Mar 8, 2022
3de539d
Import FFTW in addition to public using it
mppf Mar 8, 2022
92c37e8
Adjust ChapelStandard to public use X as X
mppf Mar 8, 2022
3297bf1
Add test cases from issue #19352
mppf Mar 8, 2022
bc6808d
Try having methods never shadow in fn disambiguation
mppf Mar 8, 2022
6602699
Remove redundant proc rank from DimensionalArr
mppf Mar 17, 2022
a37bce4
Put breakList.good back
mppf Mar 17, 2022
07f7b12
Update .good for ambiguity
mppf Mar 17, 2022
f5c7b18
Update Application8.good to be ambiguity
mppf Mar 17, 2022
8bf282e
Split check-gc-reuse-funmets into test of fns and methods
mppf Mar 17, 2022
934865f
Avoid ambiguity for local method
mppf Mar 17, 2022
6f88b4a
Use non-method operator in inlineKeyword
mppf Mar 17, 2022
d55bb2c
overload set checking uses isMoreVisible on methods
mppf Mar 17, 2022
62c74ac
Add != on chpl_taskID_t
mppf Mar 17, 2022
41020fb
Remove local chpl_taskID_t operators
mppf Mar 17, 2022
d919281
Use non-operator method to avoid ambiguity
mppf Mar 17, 2022
4d34506
Use non-method operator to avoid ambiguity
mppf Mar 17, 2022
cd1c1cb
Update .good files for public use A not bringing in A
mppf Mar 17, 2022
a8b987f
Add warning for 'public use M only;'
mppf Mar 18, 2022
d190dbf
Fix noAssignClass to error even if candidate not chosen
mppf Mar 25, 2022
d9c8469
Don't warn for public use M only X as Y
mppf Mar 25, 2022
d58b03e
Update useOnlyNothing tests
mppf Mar 25, 2022
a908f6d
Improve a comment
mppf Mar 28, 2022
013a388
Delete an out-of-date comment
mppf Mar 28, 2022
f7b8898
Change breakList.good to "I got you"
mppf Mar 28, 2022
0195a19
Improve Can't overload = error for ptr types
mppf Mar 28, 2022
5b3b6a7
Included expected Can't override = error
mppf Mar 28, 2022
e648c66
Move check for unsupported assignment overload
mppf Mar 28, 2022
268cad7
Exit loop early when possible (based on review feedback)
mppf May 6, 2022
cdb34d6
Updated modules section
mppf May 6, 2022
7469d61
Remove comment since I can't think of a counterexample
mppf May 6, 2022
6b12aba
Update module primers
mppf May 6, 2022
3d5a20a
Revert "Move check for unsupported assignment overload"
mppf May 6, 2022
184e7f0
Revert "Included expected Can't override = error"
mppf May 6, 2022
d4c63dc
Revert "Improve Can't overload = error for ptr types"
mppf May 6, 2022
ffc6988
Allow error for overloading assignment for c_string
mppf May 6, 2022
2b26e85
Accept change in output for foo2 test for now
mppf May 6, 2022
c656bb0
Improve function argument shadowing error
mppf May 6, 2022
80e8296
Include another example in modules primer
mppf May 6, 2022
b30c0fd
Revert "Fix noAssignClass to error even if candidate not chosen"
mppf May 6, 2022
c126dd1
Accept fewer errors in noAssignClass
mppf May 6, 2022
54cfad7
Add param to enable this/local this, use in autoLocalAccess tests
mppf May 9, 2022
393e94b
Address Lydia's feedback
mppf May 9, 2022
4e73421
Revert "Allow error for overloading assignment for c_string"
mppf May 10, 2022
5403f88
Fix up comments in new tests
mppf May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions compiler/AST/UseStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ bool UseStmt::hasOnlyList() const {
return isPlainUse() == false && except == false;
}

bool UseStmt::hasOnlyNothing() const {
if (hasOnlyList()) {
if (renamed.size() == 0) {
// check for named being empty or containing the empty string
if (named.size() == 0 ||
(named.size() == 1 && named[0][0] == '\0'))
return true;
}
}

return false;
}

bool UseStmt::hasExceptList() const {
return isPlainUse() == false && except == true;
}
Expand Down
7 changes: 0 additions & 7 deletions compiler/AST/baseAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,6 @@ void cleanAst() {
serializeMap.erase(key);
}

// Important: Sometimes scopeResolve will create dummy UseStmts that are
// never inserted into the tree, and will be deleted in between passes.
//
// If we do not destroy the caches, they may contain pointers back to these
// dummy uses.
destroyModuleUsesCaches();

//
// clear back pointers to dead ast instances
//
Expand Down
2 changes: 2 additions & 0 deletions compiler/include/UseStmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class UseStmt final : public VisibilityStmt {

bool hasOnlyList() const;

bool hasOnlyNothing() const;

bool hasExceptList() const;

void scopeResolve(ResolveScope* scope);
Expand Down
2 changes: 1 addition & 1 deletion compiler/include/resolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void explainAndCheckInstantiation(FnSymbol* newFn, FnSymbol* fn);

class DisambiguationContext {
public:
DisambiguationContext(CallInfo& info);
DisambiguationContext(CallInfo& info, BlockStmt* searchScope);

Vec<Symbol*>* actuals;
Expr* scope;
Expand Down
2 changes: 0 additions & 2 deletions compiler/include/scopeResolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,4 @@ BaseAST* getScope(BaseAST* ast);
void resolveUnresolvedSymExprs(BaseAST* ast);
void resolveUnmanagedBorrows(CallExpr* call);

void destroyModuleUsesCaches();

#endif
19 changes: 19 additions & 0 deletions compiler/passes/checkParsed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static void setupForCheckExplicitDeinitCalls();
static void warnUnstableUnions(AggregateType* at);
static void warnUnstableLeadingUnderscores();
static void checkOperator(FnSymbol* fn);
static void checkUseStmt(UseStmt* use);

void
checkParsed() {
Expand Down Expand Up @@ -119,6 +120,10 @@ checkParsed() {
checkExportedNames();

checkDefersAfterParsing();

forv_Vec(UseStmt, use, gUseStmts) {
checkUseStmt(use);
}
}


Expand Down Expand Up @@ -607,3 +612,17 @@ static void warnUnstableLeadingUnderscores() {
}
}
}

/* check for 'public use M only' and warn in that event since
it does nothing. (public use does not bring in the module named
unless it renames the module e.g. 'public use M as M only' */
static void checkUseStmt(UseStmt* use) {
if (!use->isPrivate && !use->isARename() && use->hasOnlyNothing()) {
const char* name = "M";
if (auto used = toUnresolvedSymExpr(use->src))
name = used->unresolved;
USR_WARN(use, "'public use %s only;' has no effect", name);
USR_PRINT("try 'public import %s;' or 'public use %s as %s only;'",
name, name, name);
}
}
Loading