Skip to content

Commit

Permalink
Merge pull request #3951 from 9rnsr/fix13424
Browse files Browse the repository at this point in the history
[REG2.066] Issue 13424 - Initialization of delegate to do-nothing default causes segfault at runtime
  • Loading branch information
WalterBright authored and 9rnsr committed Sep 7, 2014
1 parent 37b1552 commit 863f5a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/declaration.c
Expand Up @@ -1516,6 +1516,8 @@ void VarDeclaration::semantic(Scope *sc)
sc->stc &= ~(STC_TYPECTOR | STCpure | STCnothrow | STCnogc | STCref | STCdisable);

ExpInitializer *ei = init->isExpInitializer();
if (ei) // Bugzilla 13424: Preset the required type to fail in FuncLiteralDeclaration::semantic3
ei->exp = inferType(ei->exp, type);

// If inside function, there is no semantic3() call
if (sc->func)
Expand Down
11 changes: 11 additions & 0 deletions test/fail_compilation/fail13424.d
@@ -0,0 +1,11 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail13424.d(10): Error: delegate fail13424.S.__lambda2 cannot be class members
---
*/

struct S
{
void delegate(dchar) onChar = (dchar) {};
}

0 comments on commit 863f5a5

Please sign in to comment.