Skip to content

Returned parent node doesn't contain given node as child #274

@mathrick

Description

@mathrick
(let* ((parser (tsc-make-parser))
       (parsed (progn
                 (tsc-set-language parser (tree-sitter-require 'python))
                 (tsc-root-node (tsc-parse-string parser "def dupa(foo):")))))
  (message "parsed is %s" parsed)
  (tsc-traverse-mapc (lambda (node)
                       (let ((parent (tsc-get-parent node)))
                         (when (and parent
                                    (zerop (tsc-count-children parent)))
                           (error "Our parent has zero children!? %s" (tsc-node-to-sexp node)))))
                     parsed))

This results in:

tsc-traverse-mapc: Our parent has zero children!? ("_newline")

For some reason, the node returns the trailing ":" as its parent, but it is actually its sibling in the traversal order (ie. (tsc-node-eq node (tsc-get-next-sibling parent)) => t).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions