digitalmars.D.bugs - [Issue 19774] New: wrong code caused by generic variadic opIndex
- d-bugmail puremagic.com (52/52) Mar 29 2019 https://issues.dlang.org/show_bug.cgi?id=19774
https://issues.dlang.org/show_bug.cgi?id=19774 Issue ID: 19774 Summary: wrong code caused by generic variadic opIndex Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ilyayaroshenko gmail.com alias AliasSeq(T...) = T; struct C(T) { T* ptr; ~this() { ptr = null; } auto bar() const { return C!(const T)(ptr); } auto opIndex(A...)(A a) { return this; } auto foo() const { alias A = AliasSeq!(); A a; return this.bar()[a]; /+ If we replace the line above with the following line then the code would work well +/ //return this.bar.opIndex(a); } } void main() { const d = C!double(new double); auto c = d.foo; // Fails if `this.bar[a];` is used // and pass if `this.bar.opIndex(a)` is used. // Expected behaviour: pass for both cases. assert(c.ptr !is null); } --
Mar 29 2019