Skip to content

Commit

Permalink
fix Issue 7814 - ICE(tocsym.c) using scope(failure) within foreach-range
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Apr 3, 2012
1 parent c2824d4 commit c28df7d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/statement.c
Expand Up @@ -4579,7 +4579,9 @@ Catch *Catch::syntaxCopy()
}

void Catch::semantic(Scope *sc)
{ ScopeDsymbol *sym;
{
if (type && type->deco)
return;

//printf("Catch::semantic(%s)\n", ident->toChars());

Expand All @@ -4596,7 +4598,7 @@ void Catch::semantic(Scope *sc)
}
#endif

sym = new ScopeDsymbol();
ScopeDsymbol *sym = new ScopeDsymbol();
sym->parent = sc->scopesym;
sc = sc->push(sym);

Expand Down
30 changes: 30 additions & 0 deletions test/runnable/foreach5.d
Expand Up @@ -358,6 +358,35 @@ void test6659c()
assert(value == 1);
}

/***************************************/
// 7814

struct File7814
{
~this(){}
}

struct ByLine7814
{
File7814 file;

// foreach interface
@property bool empty() const { return true; }
@property char[] front() { return null; }
void popFront(){}
}

void test7814()
{
int dummy;
ByLine7814 f;
foreach (l; f) {
scope(failure) // 'failure' or 'success' fails, but 'exit' works
dummy = -1;
dummy = 0;
}
}

/***************************************/

int main()
Expand All @@ -374,6 +403,7 @@ int main()
test6659a();
test6659b();
test6659c();
test7814();

printf("Success\n");
return 0;
Expand Down

0 comments on commit c28df7d

Please sign in to comment.