sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Record type as typedef return type

Open scheglov opened this issue 3 years ago • 2 comments

@jensjoha

typedef ({int j}) R2();

I think this should be parsed as a function type alias with a record type as the return type. But it is parsed as:

[(18..19): A function body must be provided., (22..22): A function body must be provided.]
CompilationUnit
  declarations
    FunctionDeclaration
      name: typedef
      functionExpression: FunctionExpression
        parameters: FormalParameterList
          leftParenthesis: (
          leftDelimiter: {
          parameter: DefaultFormalParameter
            parameter: SimpleFormalParameter
              type: NamedType
                name: SimpleIdentifier
                  token: int
              name: j
          rightDelimiter: }
          rightParenthesis: )
        body: BlockFunctionBody
          block: Block
            leftBracket: { <synthetic>
            rightBracket: } <synthetic>
    FunctionDeclaration
      name: R2
      functionExpression: FunctionExpression
        parameters: FormalParameterList
          leftParenthesis: (
          rightParenthesis: )
        body: EmptyFunctionBody
          semicolon: ;

scheglov avatar Sep 19 '22 16:09 scheglov

See co19/LanguageFeatures/Records/record_type_annotations_A04_t06

scheglov avatar Sep 19 '22 16:09 scheglov

Also co19/LanguageFeatures/Records/record_type_annotations_A01_t04

scheglov avatar Sep 19 '22 17:09 scheglov