Tree-sitter: Parsing the empty string twice, while trying to use the previous tree leads to an assert failure

Created on 14 Aug 2020  路  3Comments  路  Source: tree-sitter/tree-sitter

In the rust program I mentioned in #530, I recently started trying to actually pass down the properly-edited previous tree to tree-stiter, instead of always passing None. After doing that I started to run into assert failures with the following message:

src/./parser.c:863: ts_parser__accept: Assertion `ts_subtree_is_eof(lookahead)' failed.

I was able to reproduce the assert failure by simply attempting to parse the empty string twice, as is done in the following code:

    let mut parser = Parser::new();

    parser.set_language(rust_lang).unwrap();

    let to_parse = "";

    let mut tree = None;

    tree = parser.parse(to_parse, tree.as_ref());

    parser.parse(to_parse, tree.as_ref());

There's a complete program containing the above code, that reproduces the assert failure, in this repo.

bug

All 3 comments

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.93. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

As a guess, I tried calling edit on the tree in my small example program, passing an &InputEdit with all default values. This seems to have prevented the assert from failing, at least in this case. I pushed the change to this branch in case that interests anyone.

Thanks for the good reproduction steps.

Was this page helpful?
0 / 5 - 0 ratings