Skip to content

Commit

Permalink
Fix Bugzilla 24848 - bad parser diagnostic for a partial MulExp
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed Nov 8, 2024
1 parent 58e4136 commit 45c2961
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -8647,7 +8647,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
error("expression expected, not `%s`", token.toChars());
Lerr:
// Anything for e, as long as it's not NULL
e = new AST.IntegerExp(loc, 0, AST.Type.tint32);
e = AST.ErrorExp.get();
nextToken();
break;
}
Expand Down
14 changes: 14 additions & 0 deletions compiler/test/fail_compilation/binexperr.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
TEST_OUTPUT:
---
fail_compilation/binexperr.d(12): Error: expression expected, not `)`
fail_compilation/binexperr.d(12): Error: missing closing `)` after `if (A1 * (__error)`
---
*/

void main()
{
struct A1 {}
if (A1*) {}
return;
}
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/e15876_3.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fail_compilation/e15876_3.d(29): Error: found `End of File` when expecting `)`
fail_compilation/e15876_3.d(29): Error: no identifier for declarator `d(_error_ = ()
{
for (__error__
0; 0)
__error; __error)
{
__error__
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/e15876_4.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fail_compilation/e15876_4.d(27): Error: found `End of File` when expecting `)`
fail_compilation/e15876_4.d(27): Error: no identifier for declarator `typeof(()
{
for (__error__
0; 0)
__error; __error)
{
__error__
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/ice15855.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fail_compilation/ice15855.d(28): Error: found `End of File` when expecting `]`
fail_compilation/ice15855.d(28): Error: no identifier for declarator `a[()
{
for (__error__
0; 0)
__error; __error)
{
__error__
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/ice8795.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TEST_OUTPUT:
---
fail_compilation/ice8795.d-mixin-14(14): Error: found `End of File` when expecting `(`
fail_compilation/ice8795.d-mixin-14(14): Error: expression expected, not `End of File`
fail_compilation/ice8795.d-mixin-14(14): Error: missing closing `)` after `switch (0`
fail_compilation/ice8795.d-mixin-14(14): Error: missing closing `)` after `switch (__error`
fail_compilation/ice8795.d-mixin-14(14): Error: found `End of File` instead of statement
fail_compilation/ice8795.d-mixin-15(15): Error: { } expected following `interface` declaration
fail_compilation/ice8795.d-mixin-15(15): Error: anonymous interfaces not allowed
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/misc_parser_err_cov1.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fail_compilation/misc_parser_err_cov1.d(40): Error: identifier or `new` expected
fail_compilation/misc_parser_err_cov1.d(41): Error: identifier or new keyword expected following `(...)`.
fail_compilation/misc_parser_err_cov1.d(41): Error: expression expected, not `;`
fail_compilation/misc_parser_err_cov1.d(42): Error: found `}` when expecting `;` following expression
fail_compilation/misc_parser_err_cov1.d(41): expression: `(__error) + 0`
fail_compilation/misc_parser_err_cov1.d(41): expression: `(__error) + (__error)`
fail_compilation/misc_parser_err_cov1.d(43): Error: matching `}` expected following compound statement, not `End of File`
fail_compilation/misc_parser_err_cov1.d(33): unmatched `{`
---
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/traits_alone.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TEST_OUTPUT:
---
fail_compilation/traits_alone.d(11): Error: found `End of File` when expecting `(`
fail_compilation/traits_alone.d(11): Error: `__traits(identifier, args...)` expected
fail_compilation/traits_alone.d(11): Error: no identifier for declarator `_error_`
fail_compilation/traits_alone.d(11): Error: no identifier for declarator `__error`
---
*/
//used to segfault
Expand Down

0 comments on commit 45c2961

Please sign in to comment.