Skip to content

Commit

Permalink
Merge pull request #1058 from 9rnsr/fix8400
Browse files Browse the repository at this point in the history
Issue 8400 - static array type cannot interpret dynamic array length
  • Loading branch information
Don Clugston committed Jul 20, 2012
2 parents bdb1f13 + b4b6211 commit 0dad668
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/mtype.c
Expand Up @@ -6369,9 +6369,7 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc,
v = s->isVarDeclaration();
if (v && id == Id::length)
{
e = v->getConstInitializer();
if (!e)
e = new VarExp(loc, v);
e = new VarExp(loc, v);
t = e->type;
if (!t)
goto Lerror;
Expand Down
11 changes: 11 additions & 0 deletions test/runnable/constfold.d
Expand Up @@ -553,6 +553,16 @@ int test4()

static assert(test4() == 24666);

/************************************/
// 8400

void test8400()
{
immutable a = [1,2];
int[a.length+0] b; // ok
int[a.length ] c; // error
}

/************************************/

int main()
Expand All @@ -561,6 +571,7 @@ int main()
test2();
test3();
test6077();
test8400();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 0dad668

Please sign in to comment.