Skip to content

Commit

Permalink
Merge pull request #2383 from hpohl/10596
Browse files Browse the repository at this point in the history
fix issue 10596 - A method with out contract and auto return type causes segfault
  • Loading branch information
WalterBright committed Jul 26, 2013
2 parents f828660 + 338998c commit 87f79bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,12 @@ void FuncDeclaration::semantic3(Scope *sc)

// BUG: need to treat parameters as const
// BUG: need to disallow returns and throws
if (inferRetType && isMember() && ((TypeFunction *)fdensure->type)->parameters)
{
// Return type was unknown in the first semantic pass
Parameter *p = (*((TypeFunction *)fdensure->type)->parameters)[0];
p->type = ((TypeFunction *)type)->nextOf();
}
fens = fens->semantic(sc2);

sc2 = sc2->pop();
Expand Down
10 changes: 10 additions & 0 deletions test/runnable/testcontracts.d
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,16 @@ class D10479 : B10479
override D10479 foo() { return null; }
}

/*******************************************/
// 10596

class Foo10596
{
auto bar()
out (result) { }
body { return 0; }
}

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

int main()
Expand Down

0 comments on commit 87f79bb

Please sign in to comment.