Skip to content

Commit

Permalink
Fix Issue 8365 - Static fixed size array of enums initialization fails
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Nov 26, 2013
1 parent 5f033bf commit a59cf5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ctfeexpr.c
Expand Up @@ -1845,7 +1845,7 @@ void recursiveBlockAssign(ArrayLiteralExp *ae, Expression *val, bool wantRef)
{
assert( ae->type->ty == Tsarray || ae->type->ty == Tarray);
#if DMDV2
Type *desttype = ((TypeArray *)ae->type)->next->castMod(0);
Type *desttype = ((TypeArray *)ae->type)->next->toBasetype()->castMod(0);
bool directblk = (val->type->toBasetype()->castMod(0))->equals(desttype);
#else
Type *desttype = ((TypeArray *)ae->type)->next;
Expand Down
7 changes: 3 additions & 4 deletions src/interpret.c
Expand Up @@ -3143,10 +3143,9 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_
{
desttype = ((TypeArray *)desttype)->next;
#if DMDV2
if (srctype->equals(desttype->castMod(0)))
#else
if (srctype->equals(desttype))
desttype = desttype->toBasetype()->castMod(0);
#endif
if (srctype->equals(desttype))
{
isBlockAssignment = true;
break;
Expand Down Expand Up @@ -4196,7 +4195,7 @@ Expression *interpretAssignToSlice(InterState *istate, CtfeGoal goal, Loc loc,
assert( existingAE->type->ty == Tsarray ||
existingAE->type->ty == Tarray);
#if DMDV2
Type *desttype = ((TypeArray *)existingAE->type)->next->castMod(0);
Type *desttype = ((TypeArray *)existingAE->type)->next->toBasetype()->castMod(0);
bool directblk = (e2->type->toBasetype()->castMod(0))->equals(desttype);
#else
Type *desttype = ((TypeArray *)existingAE->type)->next;
Expand Down
9 changes: 9 additions & 0 deletions test/compilable/interpret3.d
Expand Up @@ -2722,6 +2722,15 @@ static assert({
return true;
}());

/**************************************************
8365 - block assignment of enum arrays
**************************************************/

enum E8365 { first = 7, second, third, fourth }
static assert({ E8365[2] x; return x[0]; }() == E8365.first);
static assert({ E8365[2][2] x; return x[0][0]; }() == E8365.first);
static assert({ E8365[2][2][2] x; return x[0][0][0]; }() == E8365.first);

/**************************************************
4448 - labelled break + continue
**************************************************/
Expand Down

0 comments on commit a59cf5b

Please sign in to comment.