From 808cdd6f3429e4140df1e8a84a894de2b9fb0ba0 Mon Sep 17 00:00:00 2001 From: Geod24 Date: Mon, 29 Jul 2019 13:57:37 +0900 Subject: [PATCH] std.range.enumerate should work with a non-mutable start index The deduced type for `Enumerator` could contain type modifier (`const`, `immutable`), but the type was used directly as a state variable. --- std/range/package.d | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/std/range/package.d b/std/range/package.d index 00771b7fe0a..b707c3c02ab 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -10163,7 +10163,7 @@ do private: alias ElemType = Tuple!(Enumerator, "index", ElementType!Range, "value"); Range range; - Enumerator index; + Unqual!Enumerator index; public: ElemType front() @property @@ -10272,6 +10272,14 @@ pure @safe nothrow unittest assert(aa[1]); } +// Make sure passing qualified types works +pure @safe nothrow unittest +{ + char[4] v; + immutable start = 2; + v[2 .. $].enumerate(start); +} + pure @safe nothrow unittest { import std.internal.test.dummyrange : AllDummyRanges;