tree-sitter-haskell
tree-sitter-haskell copied to clipboard
Incremental parsing creates error node when fresh parse doesn't
I'm not sure if this is a tree-sitter-haskell bug or tree-sitter bug; but as a start I decide to report it here.
Here's what I did:
At the beginning, there's this file:
f x =
let a = 2
c = 1
in a
I create a parser and parse it, got a parse tree.
Then I edit the file, indent the second and third lines:
f x =
let a = 2
c = 1
in a
I parse the file again incrementally. Now the parse tree I get has an error node in it, even though the source code is syntactically correct.
More over, if I now create a fresh parser, and parse the edited file anew, the parse tree I get is different from the one I got from incremental parsing, and it doesn't have any error nodes.
I created a reproduce repo at here: https://github.com/casouri/tree-sitter-haskell-repo
Running run.sh
should clone and compile tree-sitter and tree-sitter-haskell, and compile and run recipe.c
. Running it should print out the two parse tree I get, the first one from incremental parsing, the second one from a fresh parse.
Parse tree of edited file:
(haskell declarations: (declarations (function name: (variable) patterns: (patterns (variable)) match: (match expression: (let_in binds: (local_binds decl: (bind name: (variable) match: (match expression: (literal (integer))))) (ERROR (variable)) expression: (variable))))))
Parse tree of a fresh parse:
(haskell declarations: (declarations (function name: (variable) patterns: (patterns (variable)) match: (match expression: (let_in binds: (local_binds decl: (bind name: (variable) match: (match expression: (literal (integer)))) decl: (bind name: (variable) match: (match expression: (literal (integer))))) expression: (variable))))))