digitalmars.D.bugs - [Issue 21020] New: named import in with block masks local symbol
- d-bugmail puremagic.com (45/45) Jul 06 2020 https://issues.dlang.org/show_bug.cgi?id=21020
https://issues.dlang.org/show_bug.cgi?id=21020 Issue ID: 21020 Summary: named import in with block masks local symbol Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: minor Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: default_357-line yahoo.de 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. --
Jul 06 2020