Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions compiler/src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -9024,7 +9024,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
values.push(e);
if (token.value == TOK.rightBracket)
break;
check(TOK.comma);
if (token.value != TOK.comma)
{
check(TOK.comma);
break;
}
nextToken();
}
check(loc, TOK.rightBracket);

Expand Down Expand Up @@ -9441,7 +9446,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
arguments.push(index);
if (token.value == TOK.rightBracket)
break;
check(TOK.comma);
if (token.value != TOK.comma)
{
check(TOK.comma);
break;
}
nextToken();
}
check(TOK.rightBracket);
inBrackets--;
Expand Down
20 changes: 20 additions & 0 deletions compiler/test/fail_compilation/fail21347.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* TEST_OUTPUT:
---
fail_compilation/fail21347.d(19): Error: expression expected, not `;`
fail_compilation/fail21347.d(20): Error: found `}` when expecting `,`
fail_compilation/fail21347.d(19): Error: found `End of File` when expecting `]`
fail_compilation/fail21347.d(19): Error: found `End of File` when expecting `)`
fail_compilation/fail21347.d(21): Error: found `End of File` when expecting `;` following expression
fail_compilation/fail21347.d(19): expression: `[(__error)]`
fail_compilation/fail21347.d(21): Error: matching `}` expected following compound statement, not `End of File`
fail_compilation/fail21347.d(18): unmatched `{`
---
*/

// https://github.com/dlang/dmd/issues/21347
// diagnostic: Parser never stops looking for ',' on array literal syntax error

void test21347()
{
([;
}
14 changes: 6 additions & 8 deletions compiler/test/fail_compilation/fail315.d
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail315.d-mixin-17(17): Error: found `;` when expecting `,`
fail_compilation/fail315.d-mixin-17(17): Error: expression expected, not `}`
fail_compilation/fail315.d-mixin-17(17): Error: found `End of File` when expecting `,`
fail_compilation/fail315.d-mixin-17(17): Error: found `End of File` when expecting `]`
fail_compilation/fail315.d-mixin-17(17): Error: found `End of File` when expecting `;` following `return` statement
fail_compilation/fail315.d-mixin-17(17): Error: matching `}` expected following compound statement, not `End of File`
fail_compilation/fail315.d-mixin-17(17): unmatched `{`
fail_compilation/fail315.d(22): Error: template instance `fail315.foo!()` error instantiating
fail_compilation/fail315.d-mixin-15(15): Error: found `;` when expecting `,`
fail_compilation/fail315.d-mixin-15(15): Error: found `}` when expecting `]`
fail_compilation/fail315.d-mixin-15(15): Error: found `End of File` when expecting `;` following `return` statement
fail_compilation/fail315.d-mixin-15(15): Error: matching `}` expected following compound statement, not `End of File`
fail_compilation/fail315.d-mixin-15(15): unmatched `{`
fail_compilation/fail315.d(20): Error: template instance `fail315.foo!()` error instantiating
---
*/

Expand Down
Loading