Skip to content
Browse files

Issue 7406 - tuple foreach doesn't work with mixed tuples

  • Loading branch information...
1 parent d762a2b commit d129dae84eed9ae2661251b7c38db30344ab67ce @9rnsr committed Jan 31, 2012
Showing with 36 additions and 0 deletions.
  1. +4 −0 src/statement.c
  2. +32 −0 test/runnable/foreach5.d
View
4 src/statement.c
@@ -1511,6 +1511,10 @@ Statement *ForeachStatement::semantic(Scope *sc)
if (arg->storageClass & STCref)
error("symbol %s cannot be ref", s->toChars());
}
+ else if (e->op == TOKtype)
+ {
+ var = new AliasDeclaration(loc, arg->ident, e->type);
+ }
else
{
arg->type = e->type;
View
32 test/runnable/foreach5.d
@@ -239,6 +239,37 @@ void test7004()
}
/***************************************/
+// 7406
+
+template TypeTuple7406(T...)
+{
+ alias T TypeTuple7406;
+}
+
+template foobar7406(T)
+{
+ enum foobar = 2;
+}
+
+void test7406()
+{
+ foreach (sym; TypeTuple7406!(int, double)) // OK
+ pragma(msg, sym.stringof);
+
+ foreach (sym; TypeTuple7406!(foobar7406)) // OK
+ pragma(msg, sym.stringof);
+
+ foreach (sym; TypeTuple7406!(test7406)) // OK
+ pragma(msg, sym.stringof);
+
+ foreach (sym; TypeTuple7406!(int, foobar7406)) // Error: type int has no value
+ pragma(msg, sym.stringof);
+
+ foreach (sym; TypeTuple7406!(int, test7406)) // Error: type int has no value
+ pragma(msg, sym.stringof);
+}
+
+/***************************************/
int main()
{
@@ -249,6 +280,7 @@ int main()
test3187();
test5605();
test7004();
+ test7406();
printf("Success\n");
return 0;

0 comments on commit d129dae

Please sign in to comment.
Something went wrong with that request. Please try again.