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

Field formal parameter with explicit record type annotation parsed incorrectly #50007

Closed
scheglov opened this issue Sep 19, 2022 · 0 comments
Closed
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues.

Comments

@scheglov
Copy link
Contributor

@jensjoha

We parse it as a function typed formal parameter instead.

class C {
  ({num n, String s}) r2;

  C(({int n, String s}) this.r2);
}

parsed as

[(41..41): Expected an identifier., (61..64): Expected to find ')'.]
class C {({num n, String s}) r2; C(({int n, String s}));}
CompilationUnit
  declarations
    ClassDeclaration
      classKeyword: class
      name: C
      leftBracket: {
      members
        FieldDeclaration
          fields: VariableDeclarationList
            type: RecordTypeAnnotation
              leftParenthesis: (
              namedFields: RecordTypeAnnotationNamedFields
                leftBracket: {
                fields
                  RecordTypeAnnotationNamedField
                    type: NamedType
                      name: SimpleIdentifier
                        token: num
                    name: n
                  RecordTypeAnnotationNamedField
                    type: NamedType
                      name: SimpleIdentifier
                        token: String
                    name: s
                rightBracket: }
              rightParenthesis: )
            variables
              VariableDeclaration
                name: r2
          semicolon: ;
        ConstructorDeclaration
          returnType: SimpleIdentifier
            token: C
          parameters: FormalParameterList
            leftParenthesis: (
            parameter: FunctionTypedFormalParameter
              name: <empty> <synthetic>
              parameters: FormalParameterList
                leftParenthesis: (
                leftDelimiter: {
                parameter: DefaultFormalParameter
                  parameter: SimpleFormalParameter
                    type: NamedType
                      name: SimpleIdentifier
                        token: int
                    name: n
                parameter: DefaultFormalParameter
                  parameter: SimpleFormalParameter
                    type: NamedType
                      name: SimpleIdentifier
                        token: String
                    name: s
                rightDelimiter: }
                rightParenthesis: )
            rightParenthesis: )
          body: EmptyFunctionBody
            semicolon: ;
      rightBracket: }
@scheglov scheglov added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Sep 19, 2022
@jensjoha jensjoha self-assigned this Sep 27, 2022
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.
Projects
None yet
Development

No branches or pull requests

2 participants