Skip to content

Commit

Permalink
fix Issue 14396 - compile error std.conv.parse!int with input range (…
Browse files Browse the repository at this point in the history
…dmd2.067)
  • Loading branch information
aG0aep6G committed Apr 12, 2015
1 parent 75da107 commit 99da04d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion std/conv.d
Expand Up @@ -1989,7 +1989,7 @@ Target parse(Target, Source)(ref Source s)
Target v = cast(Target)c;
while (!s.empty)
{
c = s.front - '0';
c = cast(typeof(c)) (s.front - '0');
if (c > 9)
break;

Expand Down Expand Up @@ -2206,6 +2206,22 @@ Lerr:
assertThrown!ConvOverflowException("-92233720368547758080".to!long());
}

// Issue 14396
@safe pure unittest
{
struct StrInputRange
{
this (string s) { str = s; }
char front() const @property { return str[front_index]; }
char popFront() { return str[front_index++]; }
bool empty() const @property { return str.length <= front_index; }
string str;
size_t front_index = 0;
}
auto input = StrInputRange("777");
assert(parse!int(input) == 777);
}

/// ditto
Target parse(Target, Source)(ref Source s, uint radix)
if (isSomeChar!(ElementType!Source) &&
Expand Down

0 comments on commit 99da04d

Please sign in to comment.