tree-sitter-scala icon indicating copy to clipboard operation
tree-sitter-scala copied to clipboard

New line in function definition for return type gives error

Open dharm-kr16 opened this issue 3 years ago • 1 comments

object Lambda
{
    def main(args:Array[String])
    : Unit
    {}
}

Above code gives error

(compilation_unit 'tests/scala/dharm.scala'
  (object_definition
    name: (identifier 'Lambda')
    body: (template_body
      (function_declaration
        name: (identifier 'main')
        parameters: (parameters
          (parameter
            name: (identifier 'args')
            type: (generic_type
              type: (type_identifier 'Array')
              type_arguments: (type_arguments
                (type_identifier 'String')
              )
            )
          )
        )
      )
      (ERROR)
      (identifier 'Unit')
      (block)
    )
  )
)

Error: Error: parse error while parsing tests/scala/dharm.scala:4,2

dharm-kr16 avatar Sep 20 '22 14:09 dharm-kr16

Following code works as expected.

object Lambda
{
    def main(args:Array[String]): Unit
    {}
}

dharm-kr16 avatar Sep 20 '22 14:09 dharm-kr16

$ tree-sitter parse examples/B.scala
(compilation_unit [0, 0] - [7, 0]
  (object_definition [0, 0] - [5, 1]
    name: (identifier [0, 7] - [0, 13])
    body: (template_body [1, 0] - [5, 1]
      (function_declaration [2, 4] - [2, 32]
        name: (identifier [2, 8] - [2, 12])
        parameters: (parameters [2, 12] - [2, 32]
          (parameter [2, 13] - [2, 31]
            name: (identifier [2, 13] - [2, 17])
            type: (generic_type [2, 18] - [2, 31]
              type: (type_identifier [2, 18] - [2, 23])
              type_arguments: (type_arguments [2, 23] - [2, 31]
                (type_identifier [2, 24] - [2, 30]))))))
      (postfix_expression [3, 4] - [3, 10]
        (operator_identifier [3, 4] - [3, 5])
        (identifier [3, 6] - [3, 10]))
      (block [4, 4] - [4, 6]))))

The result is not exactly correct, but it no longer errors, so I am closing this issue.

eed3si9n avatar Jan 14 '23 20:01 eed3si9n