Skip to content

node.parent has implicit side-effects #127

Closed

Description

@sguillia

Hi

I am encountering hard-to-debug bugs.

Sometimes, node.parent is undefined while the node actually has a parent. This happens only on leaf nodes that were accessed with a cursor.

Sometimes, reading node.parent has side-effects.

void (cursor.currentNode.parent)

This statement is supposed to do nothing right? Well, if I comment it out, tree-sitter is giving me another tree! It's giving me nodes of type _expression that disappear when uncommenting the statement.

I am having this in a large codebase. I will try to make a minimal reproducible examples but I probably won't be able to do it soon. I opended this issue just wondering if this problem is known. You can close it meanwhile if you want.

Many thanks

Activity

  1. maxbrunsfeld commented on Mar 4, 2020

    @maxbrunsfeld
    Contributor

    Are you using web-tree-sitter or node-tree-sitter?

    This issue was not known to me already. A minimal reproduction would allow me to fix it much more quickly, but I can understand how that may take time for you to set up. Thanks for the report, and apologies for the bug.

  2. sguillia commented on Mar 7, 2020

    @sguillia
    Author

    No problem, I'm already glad this project exists!

    I am using node-tree-sitter. Indeed, this issue might belong more to the binding than to the grammar.

  3. maxbrunsfeld commented on Apr 3, 2020

    @maxbrunsfeld
    Contributor

    Closing this out since the bug in the core library is fixed. I'll leave tree-sitter/node-tree-sitter#61 open until a new node-tree-sitter version is published.

  4. sguillia commented on Apr 3, 2020

    @sguillia
    Author

    @maxbrunsfeld The bug is indeed fixed, thank you!

    If you ever want an example to reproduce the implicit side-effects, before 0.16.1, here you are.
    https://github.com/sguillia/tree-sitter-ub

    (wish I had seen your message before)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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