Bug 21020 – named import in with block masks local symbol

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-07-06T12:00:03Z
Last change time
2024-12-13T19:09:56Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
FeepingCreature
Moved to GitHub: dmd#17969 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17969 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB