Comment #0 by default_357-line — 2020-07-06T12:00:03Z
Consider the following code:
void main() {
import std.stdio : writeln;
auto writeln = 42;
writeln(42);
}
It correctly errors that there's two symbols with the same name, being ambiguous.
Well, it *sort of* correctly errors - if you reverse the order, you hit https://issues.dlang.org/show_bug.cgi?id=15400 from 2015. But the principle stands.
Also, if you do:
struct S { }
void main() {
auto writeln = 42;
with (S()) {
alias writeln = (a) { };
writeln(42);
}
}
You get the expected error that 'alias writeln is shadowing variable writeln'.
However:
struct S { }
void main() {
auto writeln = 42;
with (S()) {
import std.stdio : writeln;
writeln(42);
}
}
This compiles, despite being just as ambiguous.
Comment #1 by robert.schadek — 2024-12-13T19:09:56Z