Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1078 from Poita/bug9350

Issue 9350 - findAdjacent unreachable code warning with infinite ranges
  • Loading branch information...
commit 191241ff1a0137479a660d03be7ebb874c1d7a61 2 parents c60f25e + 28b61cf
@alexrp alexrp authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 std/algorithm.d
View
5 std/algorithm.d
@@ -5460,7 +5460,8 @@ Range findAdjacent(alias pred = "a == b", Range)(Range r)
if (binaryFun!(pred)(r.front, ahead.front)) return r;
}
}
- return ahead;
+ static if (!isInfinite!Range)
+ return ahead;
}
unittest
@@ -5484,6 +5485,8 @@ unittest
ReferenceForwardRange!int rfr = new ReferenceForwardRange!int([1, 2, 3, 2, 2, 3]);
assert(equal(findAdjacent(rfr), [2, 2, 3]));
+ // Issue 9350
+ assert(!repeat(1).findAdjacent().empty);
}
// findAmong
Please sign in to comment.
Something went wrong with that request. Please try again.