Skip to content

Commit

Permalink
Merge pull request #4556 from 9rnsr/fix14406
Browse files Browse the repository at this point in the history
[REG2.068a] Issue 14406 - GIT HEAD ignores forward reference and generates wrong code
  • Loading branch information
WalterBright committed Apr 6, 2015
2 parents e50b2c9 + 4d91f33 commit 3b485c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/declaration.c
Expand Up @@ -1153,6 +1153,10 @@ void VarDeclaration::semantic(Scope *sc)
{
error("field not allowed in interface");
}
else if (aad && aad->sizeok == SIZEOKdone)
{
error("cannot be further field because it will change the determined %s size", aad->toChars());
}

/* Templates cannot add fields to aggregates
*/
Expand Down
26 changes: 26 additions & 0 deletions test/fail_compilation/fail14406.d
@@ -0,0 +1,26 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail14406.d-mixin-20(20): Error: variable fail14406.CFrop.bar_obj cannot be further field because it will change the determined CFrop size
fail_compilation/fail14406.d-mixin-25(25): Error: variable fail14406.IFrop.bar_obj field not allowed in interface
---
*/

class Foo {}

string strMixin(T)()
{
static if (T.tupleof.length) {}
return "Bar bar_obj;
static class Bar { Foo foo; }";
}

class CFrop
{
mixin(strMixin!(typeof(this)));
}

interface IFrop
{
mixin(strMixin!(typeof(this)));
}

0 comments on commit 3b485c3

Please sign in to comment.