Closed swernli closed 4 years ago
namespace Baz {
function Bar() : Unit { }
}
namespace Foo.Bar {
open Baz as Foo; // is this bad as well?
function Hello() : Unit { }
}
@cgranade No, that is fine, since everything is resolved to fully qualified names upon compilation the issue only arises if the clash is with the full name.
Fixed with #647.
This issue is copied from https://github.com/microsoft/qsharp-runtime/issues/245. When a Q# callable has a fully qualified name that exactly matches the name of another namespace, it becomes very hard to disambiguate them. This specifically causes problems in C# generation, but is really more a generally bad thing to do. We should detect and flag this in the compiler so that developers know early that the given name will not work.
For example, this code is currently accepted by the compiler:
But the function
Bar
has the fully qualified nameFoo.Bar
which collides with the namespace of the same name. This should not be allowed.