Skip to content

Commit

Permalink
fix Issue 14900 - 2.068.0 change log example does not compile
Browse files Browse the repository at this point in the history
Fix incomplete parser for statement scope declarations.
  • Loading branch information
9rnsr committed Aug 22, 2015
1 parent 107567b commit e687416
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/parse.c
Expand Up @@ -6014,8 +6014,16 @@ bool Parser::isDeclarator(Token **pt, int *haveId, int *haveTpl, TOK endtok)
t = peek(t);
}
else if (isDeclaration(t, 0, TOKrbracket, &t))
{ // It's an associative array declaration
{
// It's an associative array declaration
t = peek(t);

// ...[type].ident
if (t->value == TOKdot && peek(t)->value == TOKidentifier)
{
t = peek(t);
t = peek(t);
}
}
else
{
Expand All @@ -6024,13 +6032,27 @@ bool Parser::isDeclarator(Token **pt, int *haveId, int *haveTpl, TOK endtok)
if (!isExpression(&t))
return false;
if (t->value == TOKslice)
{ t = peek(t);
{
t = peek(t);
if (!isExpression(&t))
return false;
if (t->value != TOKrbracket)
return false;
t = peek(t);
}
else
{
if (t->value != TOKrbracket)
return false;
t = peek(t);

// ...[index].ident
if (t->value == TOKdot && peek(t)->value == TOKidentifier)
{
t = peek(t);
t = peek(t);
}
}
if (t->value != TOKrbracket)
return false;
t = peek(t);
}
continue;

Expand Down
22 changes: 22 additions & 0 deletions test/compilable/b1215.d
Expand Up @@ -83,3 +83,25 @@ alias Y14889a = X14889a[0].ExceptionType;

alias X14889b = TT14889!(A14889!Throwable);
alias Y14889b = X14889b[0].ExceptionType;

/***************************************************/
// 14889

alias TypeTuple14900(T...) = T;

struct S14900
{
alias T = int;
alias U = TypeTuple14900!(long,string);
}

alias Types14900 = TypeTuple14900!(S14900, S14900);

Types14900[0].T a14900; // Types[0] == S, then typeof(a) == S.T == int
Types14900[0].U[1] b14900; // Types[0].U == S.U, then typeof(b) == S.U[1] == string

void test14900()
{
Types14900[0].T a; // Types[0] == S, then typeof(a) == S.T == int
Types14900[0].U[1] b; // Types[0].U == S.U, then typeof(b) == S.U[1] == string
}

0 comments on commit e687416

Please sign in to comment.