Bug 4895 – isOutputRange is true for ranges which can't be output ranges

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-09-19T03:39:00Z
Last change time
2015-06-09T05:15:04Z
Assigned to
andrei
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2010-09-19T03:39:49Z
This compiles: import std.range; struct Range { @property bool empty() { return true; } @property int front() { return 7; } void popFront() { } @property Range save() { return this; } } void main() { static assert(isInputRange!(Range)); static assert(isOutputRange!(Range, int)); } It shouldn't. You can't ever assign to front. I believe that the problem is that this portion of put() ends up being compiled in: static if (is(typeof(r.front = e, r.popFront()))) { r.front = e; r.popFront(); } since putting static assert(0); in that portion of put() causing the compilation to fail.
Comment #1 by andrei — 2011-01-16T15:36:55Z
Fixed with 2.051 or earlier.