19160, "mppf", "should it be possible to shadow a symbol brought in with import?", "2022-02-02T20:46:07Z"
In Procedures — Chapel Documentation 1.25 it says that X is more specific than Y if X shadows Y.
I can understand why "shadowing" should be allowed for a use
statement but it is not so clear to me that we should allow it for the corresponding example with import
.
Here is an example with a function:
module M {
import N.f;
proc f() {
writeln("M.f");
}
proc main() {
f();
}
}
module N {
proc f() {
writeln("N.f");
}
}
This compiles today and prints M.f
. I think it should not compile, because I think of import
as creating a local symbol just like the proc
declaration does.
Here is a similar example for scope resolution:
module M {
import N.x;
var x = "M";
proc main() {
writeln(x);
}
}
module N {
var x = "N";
proc f() {
writeln("N.f");
}
}
Which also compiles and prints M
.