Skip to content

Commit

Permalink
Fix Issue 11991 - Implicit catch picks up wrong 'Throwable'
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Jan 29, 2014
1 parent bf6e00a commit a7cffd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -4738,7 +4738,13 @@ void Catch::semantic(Scope *sc)
sc = sc->push(sym);

if (!type)
type = new TypeIdentifier(Loc(), Id::Throwable);
{
// reference .object.Throwable
TypeIdentifier *tid = new TypeIdentifier(Loc(), Id::empty);
tid->addIdent(Id::object);
tid->addIdent(Id::Throwable);
type = tid;
}
type = type->semantic(loc, sc);
ClassDeclaration *cd = type->toBasetype()->isClassHandle();
if (!cd || ((cd != ClassDeclaration::throwable) && !ClassDeclaration::throwable->isBaseOf(cd, NULL)))
Expand Down
16 changes: 16 additions & 0 deletions test/compilable/compile1.d
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ static assert( !is(typeof( (){
];
})));

/**************************************************
11991
**************************************************/

void main()
{
int Throwable;
int object;
try
{
}
catch
{
}
}

/**************************************************
5796
**************************************************/
Expand Down

0 comments on commit a7cffd0

Please sign in to comment.