Disabling a root wildcard pattern doesn't work
Author: mgsloanCreated Sep 9, 2026Updated Sep 15, 2026
Labelsquery
AI Policy
- I have read the AI Policy and this issue complies with it.
Problem
A query with a wildcard root pattern still yields matches after being disabled.
AI Use: Codex + Astra was used to write the test and fix. I know what I'm doing, have reviewed it, and it looks good.
Steps to reproduce
The following regression test fails because the query yields matches despite the only pattern being disabled:
#[test]
fn test_query_disable_wildcard_pattern() {
allocations::record(|| {
let language = get_language("json");
let mut query = Query::new(&language, "(_) @any").unwrap();
query.disable_pattern(0);
let source = "1";
let mut parser = Parser::new();
parser.set_language(&language).unwrap();
let tree = parser.parse(source, None).unwrap();
let mut cursor = QueryCursor::new();
let mut matches = cursor.matches(&query, tree.root_node(), source.as_bytes());
assert!(matches.next().is_none());
});
}Expected behavior
Disabling a wildcard root pattern should work
Tree-sitter version (tree-sitter --version)
HEAD
Operating system/version
Debian forky/sid
Source: tree-sitter/tree-sitter