Open mathrick opened 4 months ago
Seems like a bug in the underlying C API of tsc-get-parent
. I could reproduce this with the Python binding:
>>> from tree_sitter import *
>>> py = Language("python.dylib", "python")
>>> p = Parser()
>>> p.set_language(py)
>>> tree = p.parse("def dupa(foo):".encode('utf-8')); tree
<tree_sitter.Tree object at 0x1027d2410>
>>>
>>> fd = tree.root_node.child(0); fd
<Node type=function_definition, start_point=(0, 0), end_point=(0, 14)>
>>>
>>> blk = fd.child(4); blk
<Node type=block, start_point=(0, 14), end_point=(0, 14)>
>>>
>>> blk.parent
<Node type=":", start_point=(0, 13), end_point=(0, 14)>
This results in:
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
).