Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad recovery when a generic type alias missing name #56912

Closed
scheglov opened this issue Oct 17, 2024 · 0 comments
Closed

Bad recovery when a generic type alias missing name #56912

scheglov opened this issue Oct 17, 2024 · 0 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-error-recovery Error recovery in the CFE. fe-analyzer-shared-parser Issues with the shared parser's handling of correct code front-end-fasta-recovery

Comments

@scheglov
Copy link
Contributor

scheglov commented Oct 17, 2024

It looks that we drop = completely, and so switch to a very synthetic legacy function type alias, although inserting a synthetic name could be a better recovery. Obviously, I don't know if it is feasible.

  test_modern_missingName() {
    var parseResult = parseStringWithErrors(r'''
typedef = int;
''');
    parseResult.assertErrors([
      error(ParserErrorCode.EXPECTED_TOKEN, 0, 7),
      error(ParserErrorCode.MISSING_IDENTIFIER, 8, 1),
      error(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, 8, 1),
      error(ParserErrorCode.EXPECTED_EXECUTABLE, 8, 1),
      error(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, 10, 3),
    ]);

    var node = parseResult.findNode.unit;
    assertParsedNodeText(node, r'''
CompilationUnit
  declarations
    FunctionTypeAlias
      typedefKeyword: typedef
      name: <empty> <synthetic>
      parameters: FormalParameterList
        leftParenthesis: ( <synthetic>
        rightParenthesis: ) <synthetic>
      semicolon: ; <synthetic>
    TopLevelVariableDeclaration
      variables: VariableDeclarationList
        variables
          VariableDeclaration
            name: int
      semicolon: ;
''');
  }
@scheglov scheglov added area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta-recovery fe-analyzer-shared-parser Issues with the shared parser's handling of correct code labels Oct 17, 2024
@johnniwinther johnniwinther added the cfe-error-recovery Error recovery in the CFE. label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-error-recovery Error recovery in the CFE. fe-analyzer-shared-parser Issues with the shared parser's handling of correct code front-end-fasta-recovery
Projects
None yet
Development

No branches or pull requests

3 participants