Skip to content

Commit

Permalink
Fixed assert on array assignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahammerl committed Feb 24, 2011
1 parent fe1724e commit 2a5c7a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions errors
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@ errortest.asy: 448.7: could not infer type of initializer
errortest.asy: 452.16: expression is not an array of inferable type
errortest.asy: 457.16: expression is not an array of inferable type
errortest.asy: 463.16: expression is not an array of inferable type
errortest.asy: 470.7: array expression cannot be used as an address
6 changes: 6 additions & 0 deletions errortest.asy
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,9 @@
for (var i : x)
;
}
{
int[] temp={0};
int[] v={0};

temp[v]= v;
}
11 changes: 10 additions & 1 deletion exp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,16 @@ void subscriptExp::transWrite(coenv &e, types::ty *t, exp *value)
array *a = transArray(e);
if (!a)
return;
assert(equivalent(a->celltype, t));

if (!equivalent(a->celltype, t))
{
em.error(getPos());
em << "array expression cannot be used as an address";

// Translate the value for errors.
value->transToType(e, t);
return;
}

index->transToType(e, types::primInt());

Expand Down

0 comments on commit 2a5c7a0

Please sign in to comment.