Skip to content

Commit

Permalink
merge D2 pull #852
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Mar 31, 2012
1 parent 11d3b00 commit e97e625
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/expression.c
Expand Up @@ -3177,6 +3177,9 @@ Expression *AssocArrayLiteralExp::semantic(Scope *sc)
printf("AssocArrayLiteralExp::semantic('%s')\n", toChars());
#endif

if (type)
return this;

// Run semantic() on each element
arrayExpressionSemantic(keys, sc);
arrayExpressionSemantic(values, sc);
Expand All @@ -3185,15 +3188,17 @@ Expression *AssocArrayLiteralExp::semantic(Scope *sc)
if (keys->dim != values->dim)
{
error("number of keys is %u, must match number of values %u", keys->dim, values->dim);
keys->setDim(0);
values->setDim(0);
return new ErrorExp();
}

Type *tkey = NULL;
Type *tvalue = NULL;
keys = arrayExpressionToCommonType(sc, keys, &tkey);
values = arrayExpressionToCommonType(sc, values, &tvalue);

if (tkey == Type::terror || tvalue == Type::terror)
return new ErrorExp;

type = new TypeAArray(tvalue, tkey);
type = type->semantic(loc, sc);
return this;
Expand Down

0 comments on commit e97e625

Please sign in to comment.