Skip to content

Commit

Permalink
fix Issue 14344 - Wrong opBinary call in construction
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Mar 26, 2015
1 parent 5c1fedc commit a39502d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/expression.c
Expand Up @@ -11411,9 +11411,18 @@ Expression *AssignExp::semantic(Scope *sc)
}
else // Bugzilla 11355
{
Expression *e = op_overload(sc);
if (e)
return e;
AggregateDeclaration *ad2 = isAggregate(e2x->type);
if (ad2 && ad2->aliasthis && !(att2 && e2x->type == att2))
{
if (!att2 && e2->type->checkAliasThisRec())
att2 = e2->type;

/* Rewrite (e1 op e2) as:
* (e1 op e2.aliasthis)
*/
e2 = new DotIdExp(e2->loc, e2, ad2->aliasthis->ident);
return semantic(sc);
}
}
}
else if (op == TOKassign)
Expand Down
31 changes: 31 additions & 0 deletions test/runnable/opover.d
Expand Up @@ -1068,6 +1068,37 @@ void test12778()
}
}

/**************************************/
// 14344

struct S14344
{
S14344 opBinary(string op)(S14344 v)
{
static assert(0);
}
S14344 opAssign()(S14344 v)
{
static assert(0);
}
}

struct S14344Mix
{
S14344 s;
alias s this;
}

class C14344
{
S14344Mix height() { return S14344Mix(); }

void update()
{
S14344 height = this.height;
}
}

/**************************************/

int main()
Expand Down

0 comments on commit a39502d

Please sign in to comment.