digitalmars.D.learn - Alias this member shadowed by imported function identifier?
- Johan Engelen (31/31) May 27 2016 The following code compiles with DMD 2.070, but not with 2.071:
- Kagamin (2/2) May 27 2016 Hmm... I wouldn't expect this to work, but still worth to report
- Steven Schveighoffer (8/39) May 27 2016 I believe in the new import rules, all module members should override
- Johan Engelen (3/6) May 28 2016 https://issues.dlang.org/show_bug.cgi?id=16086
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
May 27 2016
Hmm... I wouldn't expect this to work, but still worth to report in bugzilla.
May 27 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, JohanI 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
May 27 2016
On Friday, 27 May 2016 at 17:00:04 UTC, Steven Schveighoffer wrote: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.https://issues.dlang.org/show_bug.cgi?id=16086
May 28 2016