[Issue 17661] New: New isInputRange rejects valid input range
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jul 17 15:04:47 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17661
Issue ID: 17661
Summary: New isInputRange rejects valid input range
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: regression
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: hsteoh at quickfur.ath.cx
Code (compile with -dip25 -dip1000):
--------
import std.range.primitives;
struct C {
private S* impl;
}
struct S {
bool empty;
@property C front() return { return C(&this); }
void popFront() { }
static assert(isInputRange!S); // FAILS
}
--------
Prior to git commit 82c3371d85154b7f98b1c9187b79805a50fc59dd, the assert
passes. However, the new isInputRange checks introduced by this commit causes
the above breakage.
The problem is the new clause `typeof((R r) => r.front` in the new
isInputRange. Because S.front returns a reference to `this` it carries the
`return` annotation, so the compiler does not reject `front`. However, the
check in isInputRange does not have this annotation, so the compiler rejects it
as escaping a reference to `this`, thus causing isInputRange to fail to
recognize S as an input range.
--
More information about the Digitalmars-d-bugs
mailing list