Bug 13214 – array.opSlice one element falsy empty

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2014-07-27T10:24:00Z
Last change time
2014-07-27T14:22:27Z
Assigned to
nobody
Creator
rburners

Comments

Comment #0 by rburners — 2014-07-27T10:24:43Z
auto a = Array!int(0,1,2,3); auto r = a[1 .. 1]; assert(!r.empty); // this one should not be empty a.linearRemove(r); assert(equal(a[], [0,2,3])); This basically fails every use of one element ranges of std.array. this one is blocking my multilogger. I really would like the fixed for 2.066. I'm working on a patch. hopefully I will have it fixed in the next 8 hours
Comment #1 by rburners — 2014-07-27T10:26:19Z
empty is wrong: it should be _a > _b but that crashed a bunch of other programs
Comment #2 by issues.dlang — 2014-07-27T12:39:42Z
??? Of course a[1 .. 1] is empty. It's just like a[0 .. 0] or a[$ .. $]. If you want one element starting at index 1, then you need to do a[1 .. 2]. So, if the problem is that you think that a[1 .. 1] is supposed to be a range of length 1, starting at index 1, then you misunderstand how slice indices work. (In reply to Robert Schadek from comment #1) > empty is wrong: > > it should be _a > _b but that crashed a bunch of other programs And this comment makes no sense to me. There is no _a or _b in this example, so I don't know what you're trying to say.
Comment #3 by rburners — 2014-07-27T14:22:27Z
You're right i shouldn't think it is a bug after 1am this can be closed