tree-sitter/lib/src
Riley Bruins 6850df969d fix(query): prevent cycles when analyzing hidden children
**Problem:** `query.c` compares the current analysis state with the
previous analysis state to see if they are equal, so that it can return
early if so. This prevents redundant work. However, the comparison
function here differs from the one used for sorted insertion/lookup in
that it does not check any state data other than the child index. This
is problematic because it leads to infinite analysis when hidden nodes
have cycles.

**Solution:** Remove the custom comparison function, and apply the
insertion/lookup comparison function in place of it.

**NOTE:** This commit also changes the comparison function slightly, so
that some comparisons are reordered. Namely, for performance, it returns
early if the lhs depth is less than the rhs depth. Is this acceptable?
Tests still pass and nothing hangs in my testing, but it still seems
sketchy. Returning early if the lhs depth is greater than the rhs depth
does seem to make query analysis hang, weirdly enough... Keeping the
depth checks at the end of the loop also works, but it introduces a
noticeable performance regression (for queries that otherwise wouldn't
have had analysis cycles, of course).
2025-07-30 00:41:01 -04:00
..
portable fix(lib): add wasm32 support to portable/endian.h (#4607) 2025-07-14 17:47:40 +02:00
unicode Expand on query docs 2019-10-30 10:26:10 -07:00
wasm build(swift): include all source files 2025-01-06 01:13:04 -05:00
alloc.c fix(lib): include api.h so ts_set_allocator is visible 2024-02-27 09:21:17 -05:00
alloc.h style(lib): add parameter names in declarations that are missing them 2024-09-27 13:38:08 -04:00
array.h fix(lib): handle compiler warnings 2024-10-19 02:57:08 +00:00
atomic.h Merge branch 'master' into wasm-language 2023-10-27 12:11:43 +01:00
clock.h fix(lib): use clock_gettime on macOS again 2024-12-03 18:12:32 -05:00
error_costs.h Just call the C lib 'the library' everywhere, don't call it a 'runtime' 2019-01-10 15:22:39 -08:00
get_changed_ranges.c fix(lib): replace raw array accesses with array_get 2025-06-05 00:53:11 -04:00
get_changed_ranges.h Just call the C lib 'the library' everywhere, don't call it a 'runtime' 2019-01-10 15:22:39 -08:00
host.h Make SubtreeInlineData work on Big-Endian 2021-12-24 16:47:10 +01:00
language.c feat: add the semantic version to TSLanguage, and expose an API for retrieving it 2025-01-25 01:14:30 -05:00
language.h feat: add the semantic version to TSLanguage, and expose an API for retrieving it 2025-01-25 01:14:30 -05:00
length.h fix(lib): add saturating subtraction to prevent integer underflow 2024-12-25 04:49:39 -05:00
lexer.c chore: cleanup unused code 2025-01-21 01:17:03 -05:00
lexer.h chore: cleanup unused code 2025-01-21 01:17:03 -05:00
lib.c feat!: properly handle UTF-16 endianness encoding 2024-10-05 21:12:48 -04:00
node.c feat(lib)!: remove ts_node_child_containing_descendant 2025-01-12 22:11:30 -05:00
parser.c fix(lib): replace raw array accesses with array_get 2025-06-05 00:53:11 -04:00
parser.h fix(lib): remove duplicate TSLanguageMetadata typedef (#4268) 2025-03-06 14:14:25 -08:00
point.h chore: cleanup unused code 2025-01-21 01:17:03 -05:00
query.c fix(query): prevent cycles when analyzing hidden children 2025-07-30 00:41:01 -04:00
reduce_action.h Generate node-fields.json file 2019-02-12 11:06:18 -08:00
reusable_node.h Allocate parent nodes together with their child array 2020-10-23 12:15:44 -07:00
stack.c fix(lib): replace raw array accesses with array_get 2025-06-05 00:53:11 -04:00
stack.h Fix cases where error recovery could infinite loop (#4257) 2025-03-04 13:50:56 -08:00
subtree.c fix(lib): replace raw array accesses with array_get 2025-06-05 00:53:11 -04:00
subtree.h feat: allow parser balancing to be cancellable 2025-01-20 23:52:19 -05:00
tree.c feat!: properly handle UTF-16 endianness encoding 2024-10-05 21:12:48 -04:00
tree.h style(lib): add parameter names in declarations that are missing them 2024-09-27 13:38:08 -04:00
tree_cursor.c fix(lib): replace raw array accesses with array_get 2025-06-05 00:53:11 -04:00
tree_cursor.h style(lib): add parameter names in declarations that are missing them 2024-09-27 13:38:08 -04:00
ts_assert.h fix(lib): silence warnings with -Wpedantic 2024-09-27 12:58:26 -04:00
unicode.h feat: add the ability to specify a custom decode function 2024-10-31 22:51:40 -04:00
wasm_store.c fix(lib): replace raw array accesses with array_get 2025-06-05 00:53:11 -04:00
wasm_store.h style(lib): add parameter names in declarations that are missing them 2024-09-27 13:38:08 -04:00