You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Metrics of a file are attributed to its first function space when the root of the tree is an ERROR node #1260
When error recovery turns the root of the tree into an ERROR node, metrics() doesn't open a space for it: is_func_space only matches program, translation_unit, etc. The first function found below the root then becomes the root space, and every following space is merged into it.
For example, with this JavaScript code:
constF={a: x=>1};classA{g(){
the root of the tree is an ERROR node, and the metrics returned for the file are the ones of a function space named after the file, spanning only line 2 (the a arrow function).
It also affects the DeepSpeech snapshots in rca-output: the root of kenlm/lm/model.hh is a namespace spanning line 22, and the root of the two pywrapfst.cc files (57363 lines) is a struct spanning lines 391-395.
This was already the case before #1253, but tree-sitter 0.27 recovers from errors differently, so it now happens for files that used to get a program root.
Activity
Always open a unit space for the root of the tree