mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
Rephrase "no identifier for declarator" parse error (#20872)
This commit is contained in:
parent
4b57724c91
commit
9f33f031f0
27 changed files with 44 additions and 43 deletions
|
@ -4531,7 +4531,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
if (ident)
|
||||
checkCstyleTypeSyntax(loc, t, alt, ident);
|
||||
else if (!isThis && (t != AST.Type.terror))
|
||||
noIdentifierForDeclarator(t);
|
||||
noIdentifierForDeclarator(t, token);
|
||||
|
||||
if (isAliasDeclaration)
|
||||
{
|
||||
|
@ -4757,11 +4757,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
return a;
|
||||
}
|
||||
|
||||
/// Report an error that a declaration of type `t` is missing an identifier
|
||||
/// Report an error that a declaration of type `t` is missing an identifier and got `tok` instead
|
||||
/// The parser is expected to sit on the next token after the type.
|
||||
private void noIdentifierForDeclarator(AST.Type t)
|
||||
private void noIdentifierForDeclarator(AST.Type t, Token tok)
|
||||
{
|
||||
error("no identifier for declarator `%s`", t.toChars());
|
||||
error("variable name expected after type `%s`, not `%s`", t.toChars(), tok.toChars);
|
||||
|
||||
// A common mistake is to use a reserved keyword as an identifier, e.g. `in` or `out`
|
||||
if (token.isKeyword)
|
||||
{
|
||||
|
@ -5571,7 +5572,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
}
|
||||
at = parseType(&ai);
|
||||
if (!ai)
|
||||
noIdentifierForDeclarator(at);
|
||||
noIdentifierForDeclarator(at, token);
|
||||
Larg:
|
||||
auto p = new AST.Parameter(aloc, storageClass, at, ai, null, null);
|
||||
parameters.push(p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue