Skip to content

Commit

Permalink
Merge pull request #3732 from 9rnsr/fix13081
Browse files Browse the repository at this point in the history
[REG2.066a] Issue 13081 - ICE with alias this and opSlice
  • Loading branch information
yebblies committed Jul 9, 2014
2 parents 86b9076 + 9c13bc3 commit e85556a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/expression.c
Expand Up @@ -10987,9 +10987,10 @@ Expression *AssignExp::semantic(Scope *sc)
if (ex->op == TOKerror)
return ex;

e2 = e2->semantic(sc);
if (e2->op == TOKerror)
return e2;
Expression *e2x = e2->semantic(sc);
if (e2x->op == TOKerror)
return e2x;
e2 = e2x;

Expressions *a = (Expressions *)ae->arguments->copy();
a->insert(0, e2);
Expand Down Expand Up @@ -13643,33 +13644,37 @@ Expression *CondExp::semantic(Scope *sc)
if (type)
return this;

econd = econd->semantic(sc);
econd = resolveProperties(sc, econd);
econd = econd->checkToPointer();
econd = econd->checkToBoolean(sc);
Expression *ec = econd->semantic(sc);
ec = resolveProperties(sc, ec);
ec = ec->checkToPointer();
ec = ec->checkToBoolean(sc);

unsigned cs0 = sc->callSuper;
unsigned *fi0 = sc->saveFieldInit();
e1 = e1->semantic(sc);
e1 = resolveProperties(sc, e1);
Expression *e1x = e1->semantic(sc);
e1x = resolveProperties(sc, e1x);

unsigned cs1 = sc->callSuper;
unsigned *fi1 = sc->fieldinit;
sc->callSuper = cs0;
sc->fieldinit = fi0;
e2 = e2->semantic(sc);
e2 = resolveProperties(sc, e2);
Expression *e2x = e2->semantic(sc);
e2x = resolveProperties(sc, e2x);

sc->mergeCallSuper(loc, cs1);
sc->mergeFieldInit(loc, fi1);

if (econd->type == Type::terror)
return econd;
if (e1->type == Type::terror)
return e1;
if (e2->type == Type::terror)
return e2;
if (ec->op == TOKerror) return ec;
if (ec->type == Type::terror) return new ErrorExp();
econd = ec;

if (e1x->op == TOKerror) return e1x;
if (e1x->type == Type::terror) return new ErrorExp();
e1 = e1x;

if (e2x->op == TOKerror) return e2x;
if (e2x->type == Type::terror) return new ErrorExp();
e2 = e2x;

// If either operand is void, the result is void
Type *t1 = e1->type;
Expand Down
29 changes: 29 additions & 0 deletions test/fail_compilation/ice13081.d
@@ -0,0 +1,29 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice13081.d(17): Error: undefined identifier node
fail_compilation/ice13081.d(17): Error: undefined identifier data
fail_compilation/ice13081.d(17): Error: undefined identifier node
fail_compilation/ice13081.d(28): Error: template instance ice13081.Cube!(SparseDataStore) error instantiating
---
*/

struct Cube(StorageT)
{
StorageT datastore;
alias datastore this;
auto seed()
{
this[] = node.data ? data : node.data;
}
}

class SparseDataStore
{
auto opSlice() {}
}

void main()
{
Cube!SparseDataStore c;
}

0 comments on commit e85556a

Please sign in to comment.