mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Merge pull request #11190 from kinke/postblit
Fix Issue 11292 - Cannot re-initialize a const field in postblit merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
This commit is contained in:
commit
7910886040
2 changed files with 12 additions and 4 deletions
|
@ -89,15 +89,18 @@ bool modifyFieldVar(Loc loc, Scope* sc, VarDeclaration var, Expression e1)
|
|||
if (s)
|
||||
fd = s.isFuncDeclaration();
|
||||
if (fd &&
|
||||
((fd.isCtorDeclaration() && var.isField()) ||
|
||||
(fd.isStaticCtorDeclaration() && !var.isField())) &&
|
||||
((var.isField() && (fd.isCtorDeclaration() || fd.isPostBlitDeclaration())) ||
|
||||
(!var.isField() && fd.isStaticCtorDeclaration())) &&
|
||||
fd.toParentDecl() == var.toParent2() &&
|
||||
(!e1 || e1.op == TOK.this_))
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
var.ctorinit = true;
|
||||
//printf("setting ctorinit\n");
|
||||
if (!fd.isPostBlitDeclaration())
|
||||
{
|
||||
var.ctorinit = true;
|
||||
//printf("setting ctorinit\n");
|
||||
}
|
||||
|
||||
if (var.isField() && sc.ctorflow.fieldinit.length && !sc.intypeof)
|
||||
{
|
||||
|
|
5
test/compilable/test11292.d
Normal file
5
test/compilable/test11292.d
Normal file
|
@ -0,0 +1,5 @@
|
|||
struct S
|
||||
{
|
||||
immutable int x;
|
||||
this(this) { x = 1; }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue