Skip to content

Conversation

@rmuir
Copy link
Contributor

@rmuir rmuir commented Aug 23, 2025

Reported bug of missing functions (#413) is caused by this query pattern:

((declaration) @root @start
  .
  (function_definition) @symbol @end
  (#set! "kind" "Function"))

Removing the pattern fixes the bug and causes no regressions in tests. The pattern was introduced in 9135045 but it is not clear what its purpose is: all functions should be matched by the simple (function_definition) query immediately after it.

The example from #413 and a few additional tests from tree-sitter-c's test corpus were added.

Closes #413

Note: if by any chance you happen to remember what this pattern was trying to accomplish, I can look to address/test for it.

Reported bug of missing functions (stevearc#413) is caused by this query pattern:

```
((declaration) @root @start
  .
  (function_definition) @symbol @EnD
  (#set! "kind" "Function"))
```

Removing the pattern fixes the bug and causes no regressions in tests. The pattern was introduced in
stevearc@9135045 but it is
not clear what its purpose is: all functions should be matched by the simple `(function_definition)`
query immediately after it.

The example from stevearc#413 and a few additional tests from tree-sitter-c's test corpus were added.

Closes stevearc#413

Signed-off-by: Robert Muir <[email protected]>
@github-actions github-actions bot requested a review from stevearc August 23, 2025 16:01
@stevearc
Copy link
Owner

The tests should have 100% coverage of the treesitter queries, so you can do pretty much whatever with the queries as long as the tests still pass. Thanks for the fix!

@stevearc stevearc merged commit 62a5a31 into stevearc:master Aug 24, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C query issue: Function after global variable is not detected

2 participants