Skip to content

Incorrect parsing of function declaration #172

@streichsbaer

Description

@streichsbaer

Version that produces this error

https://github.com/fwcd/tree-sitter-kotlin.git, tag = "0.3.8"

A code sample showing the error

This code is taken from the Corda framework.

package net.corda.node.services.statemachine

class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
                              override val logic: FlowLogic<R>,
                              scheduler: FiberScheduler,
                              override val creationTime: Long = System.currentTimeMillis(),
                              val serializedTelemetry: SerializedTelemetry? = null
) : Fiber<Unit>(id.toString(), scheduler), FlowStateMachine<R>, FlowFiber {

    @Suspendable
    override fun <R : Any> suspend(ioRequest: FlowIORequest<R>, maySkipCheckpoint: Boolean): R {
        val serializationContext = TransientReference(transientValues.checkpointSerializationContext)
        return uncheckedCast(processEventsUntilFlowIsResumed(
                isDbTransactionOpenOnEntry = false,
                isDbTransactionOpenOnExit = true
        ))
    }
}

Show the error node

(source_file [0, 0] - [17, 1]
  (package_header [0, 0] - [0, 44]
    (identifier [0, 8] - [0, 44]
      (simple_identifier [0, 8] - [0, 11])
      (simple_identifier [0, 12] - [0, 17])
      (simple_identifier [0, 18] - [0, 22])
      (simple_identifier [0, 23] - [0, 31])
      (simple_identifier [0, 32] - [0, 44])))
  (class_declaration [2, 0] - [16, 5]
    (type_identifier [2, 6] - [2, 26])
    (type_parameters [2, 26] - [2, 29]
      (type_parameter [2, 27] - [2, 28]
        (type_identifier [2, 27] - [2, 28])))
    (primary_constructor [2, 29] - [7, 1]
      (class_parameter [2, 30] - [2, 64]
        (modifiers [2, 30] - [2, 38]
          (member_modifier [2, 30] - [2, 38]))
        (binding_pattern_kind [2, 39] - [2, 42])
        (simple_identifier [2, 43] - [2, 45])
        (user_type [2, 47] - [2, 64]
          (type_identifier [2, 47] - [2, 64])))
      (class_parameter [3, 30] - [3, 62]
        (modifiers [3, 30] - [3, 38]
          (member_modifier [3, 30] - [3, 38]))
        (binding_pattern_kind [3, 39] - [3, 42])
        (simple_identifier [3, 43] - [3, 48])
        (user_type [3, 50] - [3, 62]
          (type_identifier [3, 50] - [3, 59])
          (type_arguments [3, 59] - [3, 62]
            (type_projection [3, 60] - [3, 61]
              (user_type [3, 60] - [3, 61]
                (type_identifier [3, 60] - [3, 61]))))))
      (class_parameter [4, 30] - [4, 55]
        (simple_identifier [4, 30] - [4, 39])
        (user_type [4, 41] - [4, 55]
          (type_identifier [4, 41] - [4, 55])))
      (class_parameter [5, 30] - [5, 90]
        (modifiers [5, 30] - [5, 38]
          (member_modifier [5, 30] - [5, 38]))
        (binding_pattern_kind [5, 39] - [5, 42])
        (simple_identifier [5, 43] - [5, 55])
        (user_type [5, 57] - [5, 61]
          (type_identifier [5, 57] - [5, 61]))
        (call_expression [5, 64] - [5, 90]
          (navigation_expression [5, 64] - [5, 88]
            (simple_identifier [5, 64] - [5, 70])
            (navigation_suffix [5, 70] - [5, 88]
              (simple_identifier [5, 71] - [5, 88])))
          (call_suffix [5, 88] - [5, 90]
            (value_arguments [5, 88] - [5, 90]))))
      (class_parameter [6, 30] - [6, 82]
        (binding_pattern_kind [6, 30] - [6, 33])
        (simple_identifier [6, 34] - [6, 53])
        (nullable_type [6, 55] - [6, 75]
          (user_type [6, 55] - [6, 74]
            (type_identifier [6, 55] - [6, 74])))
        (null_literal [6, 78] - [6, 82])))
    (delegation_specifier [7, 4] - [7, 41]
      (constructor_invocation [7, 4] - [7, 41]
        (user_type [7, 4] - [7, 15]
          (type_identifier [7, 4] - [7, 9])
          (type_arguments [7, 9] - [7, 15]
            (type_projection [7, 10] - [7, 14]
              (user_type [7, 10] - [7, 14]
                (type_identifier [7, 10] - [7, 14])))))
        (value_arguments [7, 15] - [7, 41]
          (value_argument [7, 16] - [7, 29]
            (call_expression [7, 16] - [7, 29]
              (navigation_expression [7, 16] - [7, 27]
                (simple_identifier [7, 16] - [7, 18])
                (navigation_suffix [7, 18] - [7, 27]
                  (simple_identifier [7, 19] - [7, 27])))
              (call_suffix [7, 27] - [7, 29]
                (value_arguments [7, 27] - [7, 29]))))
          (value_argument [7, 31] - [7, 40]
            (simple_identifier [7, 31] - [7, 40])))))
    (delegation_specifier [7, 43] - [7, 62]
      (user_type [7, 43] - [7, 62]
        (type_identifier [7, 43] - [7, 59])
        (type_arguments [7, 59] - [7, 62]
          (type_projection [7, 60] - [7, 61]
            (user_type [7, 60] - [7, 61]
              (type_identifier [7, 60] - [7, 61]))))))
    (delegation_specifier [7, 64] - [7, 73]
      (user_type [7, 64] - [7, 73]
        (type_identifier [7, 64] - [7, 73])))
    (class_body [7, 74] - [16, 5]
      (function_declaration [9, 4] - [15, 9]
        (modifiers [9, 4] - [10, 12]
          (annotation [9, 4] - [9, 16]
            (user_type [9, 5] - [9, 16]
              (type_identifier [9, 5] - [9, 16])))
          (member_modifier [10, 4] - [10, 12]))
        (type_parameters [10, 17] - [10, 26]
          (type_parameter [10, 18] - [10, 25]
            (type_identifier [10, 18] - [10, 19])
            (user_type [10, 22] - [10, 25]
              (type_identifier [10, 22] - [10, 25]))))
        receiver: (receiver_type [10, 27] - [10, 91]
          (type_modifiers [10, 27] - [10, 34])
          (parenthesized_type [10, 34] - [10, 91]
            (user_type [10, 35] - [10, 62]
              (type_identifier [10, 35] - [10, 44])
              (ERROR [10, 44] - [10, 59])
              (type_arguments [10, 59] - [10, 62]
                (type_projection [10, 60] - [10, 61]
                  (user_type [10, 60] - [10, 61]
                    (type_identifier [10, 60] - [10, 61])))))
            (ERROR [10, 62] - [10, 90])))
        (ERROR [10, 91] - [11, 69]
          (simple_identifier [10, 93] - [10, 94])
          (simple_identifier [11, 12] - [11, 32])
          (simple_identifier [11, 35] - [11, 53])
          (simple_identifier [11, 54] - [11, 69]))
        (simple_identifier [11, 70] - [11, 100])
        (ERROR [11, 100] - [12, 60]
          (simple_identifier [12, 29] - [12, 60]))
        (function_value_parameters [12, 60] - [15, 9]
          (ERROR [13, 16] - [14, 48]
            (simple_identifier [13, 16] - [13, 42]))))
      (ERROR [15, 9] - [15, 10])))
  (ERROR [17, 0] - [17, 1]))

Where are you experiencing this error?

I'm using the tree-sitter-kotlin pypi package (via tree-sitter-kotlin = {git = "https://github.com/fwcd/tree-sitter-kotlin.git", tag = "0.3.8"} in combination tree-sitter 0.24.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions