Skip to content

Commit

Permalink
Merge pull request #4110 from yebblies/issue13679
Browse files Browse the repository at this point in the history
Issue 13679 - foreach_reverse is allowed for AAs
  • Loading branch information
MartinNowak committed Nov 10, 2014
2 parents 64150cf + da85c97 commit 7b130d0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/statement.c
Expand Up @@ -2042,6 +2042,8 @@ Statement *ForeachStatement::semantic(Scope *sc)
}

case Taarray:
if (op == TOKforeach_reverse)
warning("cannot use foreach_reverse with an associative array");
if (!checkForArgTypes())
return this;

Expand Down
15 changes: 15 additions & 0 deletions test/fail_compilation/warn13679.d
@@ -0,0 +1,15 @@
// REQUIRED_ARGS: -w
// PERMUTE_ARGS:

/*
TEST_OUTPUT:
---
fail_compilation/warn13679.d(14): Warning: cannot use foreach_reverse with an associative array
---
*/

void main()
{
int[int] aa;
foreach_reverse(k, v; aa) {}
}

0 comments on commit 7b130d0

Please sign in to comment.