Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 7892 - Compiler-generated struct copies can result in errors when ctor is @disable'd #2596

Merged
1 commit merged into from Sep 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/declaration.c
Expand Up @@ -1296,11 +1296,12 @@ void VarDeclaration::semantic(Scope *sc)
}
}

if (!(storage_class & (STCctfe | STCref)) && tbn->ty == Tstruct &&
if (!(storage_class & (STCctfe | STCref | STCresult)) && tbn->ty == Tstruct &&
((TypeStruct *)tbn)->sym->noDefaultCtor)
{
if (!init)
{ if (isField())
{
if (isField())
/* For fields, we'll check the constructor later to make sure it is initialized
*/
storage_class |= STCnodefaultctor;
Expand Down
30 changes: 30 additions & 0 deletions test/runnable/testcontracts.d
Expand Up @@ -457,6 +457,36 @@ class DC7883 : CC7883
body { return 1; }
}

/*******************************************/
// 7892

struct S7892
{
@disable this();
this(int x) {}
}

S7892 f7892()
out (result) {} // case 1
body
{
return S7892(1);
}

interface I7892
{
S7892 f();
}
class C7892
{
invariant() {} // case 2

S7892 f()
{
return S7892(1);
}
}

/*******************************************/
// 8066

Expand Down