Bug 16480 – Local selective imports hide member functions

Status
RESOLVED
Resolution
INVALID
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-09-09T10:55:41Z
Last change time
2022-07-27T10:06:15Z
Assigned to
No Owner
Creator
John Colvin

Comments

Comment #0 by john.loughran.colvin — 2016-09-09T10:55:41Z
struct S0 { bool empty() { return false; } } struct S1 { import std.range : empty; bool empty() { return false; } } pragma(msg, typeof(S0.empty)); // bool() pragma(msg, typeof(S1.empty)); // void
Comment #1 by bitter.taste — 2016-12-20T19:17:13Z
It doesn't really look like a bug beside the fact that the compiler doesn't care about the methods being redefined... The first one to appear wins, easy! ``` struct S0 { bool empty() { return false; } int empty() { return false; } } pragma(msg, typeof(S0.empty)); // still bool() ```
Comment #2 by razvan.nitu1305 — 2022-07-27T10:06:15Z
Yes, this is not a bug. The alias introduces empty in the overload set and when used with pragma it simply selects the first overload it finds. For example: ``` struct S0 { bool empty() { return false; } } struct S1 { void empty(int a) {} bool empty() { return false; } //import std.range : empty; } pragma(msg, typeof(S0.empty)); // bool() pragma(msg, typeof(S1.empty)); // void ``` This code has the same behavior. No shadowing is taking place. Closing as invalid.