Skip to content

Commit

Permalink
Fix Issue 19415 - return non-copyable struct fails if member function…
Browse files Browse the repository at this point in the history
… has return attribute
  • Loading branch information
RazvanN7 committed Nov 21, 2018
1 parent 577dda9 commit 487a8c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dmd/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -5506,7 +5506,9 @@ extern (C++) final class TypeStruct : Type
// Probably should cache this information in sym rather than recompute
StructDeclaration s = sym;

sym.size(Loc.initial); // give error for forward references
if (sym.members && !sym.determineFields() && sym.type != Type.terror)
error(sym.loc, "no size because of forward references");

foreach (VarDeclaration v; s.fields)
{
if (v.storage_class & STC.ref_ || v.hasPointers())
Expand Down
14 changes: 14 additions & 0 deletions test/compilable/test19145.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://issues.dlang.org/show_bug.cgi?id=19415

struct S
{
int x;
S foo() return { return S(x); }
this(this) @disable;
}

S bar()
{
S s;
return s; // Error: struct `S` is not copyable because it is annotated with @disable
}

0 comments on commit 487a8c5

Please sign in to comment.