Skip to content

Commit

Permalink
fix Issue 11062 - inline ice with alias this and opIndexAssign
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Sep 20, 2013
1 parent e80b9cf commit 1f5c143
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -11168,7 +11168,8 @@ Expression *AssignExp::semantic(Scope *sc)

ae->e1 = ae->e1->semantic(sc);
ae->e1 = resolveProperties(sc, ae->e1);
Expression *e1 = ae->e1;
Expression *ae1old = ae->e1;

Type *t1 = ae->e1->type->toBasetype();
if (t1->ty == Tstruct)
{
Expand All @@ -11187,7 +11188,7 @@ Expression *AssignExp::semantic(Scope *sc)
Expressions *a = (Expressions *)ae->arguments->copy();
a->insert(0, e2);

Expression *e = new DotIdExp(loc, e1, Id::indexass);
Expression *e = new DotIdExp(loc, ae->e1, Id::indexass);
e = new CallExp(loc, e, a);
e = combine(e0, e);
e = e->semantic(sc);
Expand All @@ -11200,8 +11201,8 @@ Expression *AssignExp::semantic(Scope *sc)
{
if (!att1 && t1->checkAliasThisRec())
att1 = t1;
e1 = resolveAliasThis(sc, e1);
t1 = e1->type->toBasetype();
ae->e1 = resolveAliasThis(sc, ae->e1);
t1 = ae->e1->type->toBasetype();
if (t1->ty == Tstruct)
{
ad = ((TypeStruct *)t1)->sym;
Expand All @@ -11213,6 +11214,8 @@ Expression *AssignExp::semantic(Scope *sc)
goto L1;
}
}

ae->e1 = ae1old; // restore
}
/* Look for operator overloading of a[i..j]=value.
* Do it before semantic() otherwise the a[i..j] will have been
Expand All @@ -11225,7 +11228,8 @@ Expression *AssignExp::semantic(Scope *sc)

ae->e1 = ae->e1->semantic(sc);
ae->e1 = resolveProperties(sc, ae->e1);
Expression *e1 = ae->e1;
Expression *ae1old = ae->e1;

Type *t1 = ae->e1->type->toBasetype();
if (t1->ty == Tstruct)
{
Expand All @@ -11248,7 +11252,7 @@ Expression *AssignExp::semantic(Scope *sc)
a->push(ae->lwr);
a->push(ae->upr);
}
Expression *e = new DotIdExp(loc, e1, Id::sliceass);
Expression *e = new DotIdExp(loc, ae->e1, Id::sliceass);
e = new CallExp(loc, e, a);
e = combine(e0, e);
e = e->semantic(sc);
Expand All @@ -11261,8 +11265,8 @@ Expression *AssignExp::semantic(Scope *sc)
{
if (!att1 && t1->checkAliasThisRec())
att1 = t1;
e1 = resolveAliasThis(sc, e1);
t1 = e1->type->toBasetype();
ae->e1 = resolveAliasThis(sc, ae->e1);
t1 = ae->e1->type->toBasetype();
if (t1->ty == Tstruct)
{
ad = ((TypeStruct *)t1)->sym;
Expand All @@ -11274,6 +11278,8 @@ Expression *AssignExp::semantic(Scope *sc)
goto L2;
}
}

ae->e1 = ae1old; // restore
}

/* With UFCS, e.f = value
Expand Down
45 changes: 45 additions & 0 deletions test/runnable/opover2.d
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,50 @@ void test10567()
+/
}

/**************************************/
// 11062

struct S11062ia
{
struct S1
{
void opIndexAssign(int val, int key) {}
}
struct S2
{
S1 headers;
}

private S2 m_obj;
@property S2 get() { return m_obj; }
alias get this;
}

struct S11062sa
{
struct S1
{
void opSliceAssign(int val, int lwr, int upr) {}
}
struct S2
{
S1 headers;
}

private S2 m_obj;
@property S2 get() { return m_obj; }
alias get this;
}

void test11062()
{
auto sia = S11062ia();
sia.headers[1] = 1; // bug

auto ssa = S11062sa();
ssa.headers[1..2] = 1; // bug
}

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

int main()
Expand Down Expand Up @@ -1428,6 +1472,7 @@ int main()
test10064();
test10394();
test10567();
test11062();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 1f5c143

Please sign in to comment.