digitalmars.D.bugs - [Issue 20009] New: isForwardRange doesn't work with alias range this
- d-bugmail puremagic.com (33/33) Jun 27 2019 https://issues.dlang.org/show_bug.cgi?id=20009
https://issues.dlang.org/show_bug.cgi?id=20009 Issue ID: 20009 Summary: isForwardRange doesn't work with alias range this or inheritance Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: ali.akhtarzada gmail.com struct FR { bool empty = true; void popFront() {} auto front() { return 0; } FR save() { return this; } } struct S { FR range; alias range this; } pragma(msg, isInputRange!S); // true pragma(msg, isForwardRange!S); // false It's because isForwardRange is defined as: isInputRange!R && is(ReturnType!((R r) => r.save) == R); But it should be: isInputRange!R && is(R : ReturnType!((R r) => r.save)); The same thing will happen if you try an inherit from an interface that is a forward range, and if the save function returns the base class it will fail. --
Jun 27 2019