Skip to content

Commit

Permalink
Merge pull request #378 from dawgfoto/master
Browse files Browse the repository at this point in the history
fix segfault for underfitted foreach tuple expansion
  • Loading branch information
WalterBright committed Sep 13, 2011
2 parents 7569c39 + d54c1fb commit 569077b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
if (pos == -1)
break;
}
if (exps->dim > dim)
if (exps->dim != dim)
goto Lrangeerr;

for (size_t i = 0; i < dim; i++)
Expand Down
11 changes: 11 additions & 0 deletions test/fail_compilation/fail352.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

struct Range {
bool empty;
int front() { return 0; }
void popFront() { empty = true; }
}

void main() {
// no index for range foreach
foreach(i, v; Range()) {}
}

0 comments on commit 569077b

Please sign in to comment.