Skip to content

Commit

Permalink
Fix issue 20928
Browse files Browse the repository at this point in the history
  • Loading branch information
Simen Kjærås committed Jun 15, 2020
1 parent b2e2ac0 commit b42cd6e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion std/algorithm/iteration.d
Expand Up @@ -630,7 +630,7 @@ private struct MapResult(alias fun, Range)

static if (isRandomAccessRange!R)
{
static if (is(typeof(_input[ulong.max])))
static if (is(typeof(Range.init[ulong.max])))
private alias opIndex_t = ulong;
else
private alias opIndex_t = uint;
Expand Down Expand Up @@ -870,6 +870,23 @@ private struct MapResult(alias fun, Range)
assert(m.front == immutable(S)(null));
}

// Issue 20928
@safe unittest
{
struct Always3
{
enum empty = false;
auto save() { return this; }
long front() { return 3; }
void popFront() {}
long opIndex(ulong i) { return 3; }
long opIndex(ulong i) immutable { return 3; };
}

import std.algorithm.iteration : map;
Always3.init.map!(e => e)[ulong.max];
}

// each
/**
Eagerly iterates over `r` and calls `fun` over _each element.
Expand Down

0 comments on commit b42cd6e

Please sign in to comment.