Alias this member shadowed by imported function identifier?
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 27 10:00:04 PDT 2016
On 5/27/16 9:33 AM, Johan Engelen wrote:
> 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
>
> Is this because of the new import rules, or is it a bug?
>
> Thanks,
> Johan
>
I believe in the new import rules, all module members should override
any imported ones, unless the import is renaming (which is equivalent to
aliasing into your local namespace the symbol).
Now, the question here is, when does alias this kick in? I would say it
should follow alias this before looking outside the module, so I say
it's a bug.
-Steve
More information about the Digitalmars-d-learn
mailing list