Bug 16086 – Imported function name shadows alias this member
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-28T09:56:32Z
Last change time
2018-11-05T15:36:56Z
Assigned to
Martin Nowak
Creator
Johan Engelen
Comments
Comment #0 by jbc.engelen — 2016-05-28T09:56:32Z
The following code compiles with DMD 2.070, but not with 2.071:
```
module mod;
import std.range;
struct S
{
struct Inner
{
int unique_identifier_name;
int tail;
}
Inner inner;
alias inner this;
auto works()
{
return unique_identifier_name;
}
auto fails()
{
return tail; // Line 22
// The workaround: return this.tail;
}
}
```
The 2.071 error is:
tail.d(22): Error: template tail(Range)(Range range, size_t n) if (isInputRange!Range && !isInfinite!Range && (hasLength!Range || isForwardRange!Range)) has no type
See forum thread: http://forum.dlang.org/post/[email protected]
Comment #1 by bugzilla — 2016-06-07T05:48:32Z
The trouble is it is picking up std.range.tail rather than the alias this.
Comment #2 by code — 2016-09-12T04:14:16Z
This issue is not a result of the lookup change, but happens because tail was newly added to std.range in 2.071.x.
Alias this and opDispatch was and still is resolved after an exhaustive search.
Might be worthwhile to think about performing alias this resolution before searching imported modules, to avoid such breakage due to upstream library changes.
Comment #3 by razvan.nitu1305 — 2018-10-29T12:03:35Z