Skip to content

Commit

Permalink
fix Issue 12902 - [ICE] Assertion failure '!ae->lengthVar' in 'expres…
Browse files Browse the repository at this point in the history
…sion.c' when using `opDollar`
  • Loading branch information
9rnsr committed Jun 15, 2014
1 parent d4ea0c0 commit 51400f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/expression.c
Expand Up @@ -10986,6 +10986,10 @@ Expression *AssignExp::semantic(Scope *sc)
if (ex->op == TOKerror)
return ex;

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

Expressions *a = (Expressions *)ae->arguments->copy();
a->insert(0, e2);

Expand Down
7 changes: 7 additions & 0 deletions src/opover.c
Expand Up @@ -956,6 +956,13 @@ Expression *op_overload(Expression *e, Scope *sc)
return;
}

e->e2 = e->e2->semantic(sc);
if (e->e2->op == TOKerror)
{
result = e->e2;
return;
}

Expressions *a = (Expressions *)ae->arguments->copy();
a->insert(0, e->e2);

Expand Down
21 changes: 21 additions & 0 deletions test/fail_compilation/ice12902.d
@@ -0,0 +1,21 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice12902.d(20): Error: variable ice12902.main.__dollar type void is inferred from initializer s.opDollar(), and variables cannot be of type void
fail_compilation/ice12902.d(20): Error: expression s.opDollar() is void and has no value
---
*/

struct S
{
void opDollar() { }
void opIndex() { }
void opIndexAssign() { }
void opSliceAssign() { }
}

void main()
{
S s;
s[] = s[$];
}

0 comments on commit 51400f7

Please sign in to comment.