16317, “lydia-duncan”, “Should we report all re-export points in the case of a symbol conflict?”, “2020-08-31T21:58:35Z”
Summary of Problem
Re-exporting essentially brings a symbol name into the scope with the re-export. With #16304, we now report the line number for the re-export in addition to the definition point of the symbol that conflicts. However, Engin brings up the excellent point that such a symbol could have been re-exported multiple times. In that case, should we report all the re-export points? Or just the most recent one, since the most recent one is what causes the conflict?
Argument in favor of all the re-export points:
- There will be no confusion when the re-export point refers to a module other than where the symbol is ultimately defined
Argument in favor of just the most recent one:
- The most recent one is likely the only one the user has any control over
- If we find a symbol through a long public use chain, we don’t say anything about the intervening use statements and users handle it just fine
Steps to Reproduce
Source Code:
module A {
var x = 2;
}
module B {
var x = 4;
}
module C {
public import A.x; // The first re-export (not reported on failure)
}
module D {
public import C.x; // The second re-export (reported on failure)
}
module Z {
use D, B;
proc main() {
writeln(x);
}
}
Output:
multipleDef-multipleReexport.chpl:2: error: symbol x is multiply defined
note: 'x' was reexported at multipleDef-multipleReexport.chpl:12
multipleDef-multipleReexport.chpl:5: note: also defined here
Compile command:
chpl multipleDef-multipleReexport.chpl
Associated Future Test(s):
No future, but the test above lives at test/visibility/import/edgeCases/multipleDef-multipleReexport.chpl
#16304
Configuration Information
- Output of
chpl --version
: 1.23.0 (pre-release)