fix(query): correct last_child_step_index in cases where a new step

wasn't created.

This fixes an OOB access to `self.steps` when a last child anchor
immediately follows a predicate.
This commit is contained in:
Will Lillis 2025-05-01 23:46:40 -04:00
parent cc634236b1
commit b1d2b7cfb8
2 changed files with 15 additions and 1 deletions

View file

@ -5621,3 +5621,14 @@ const foo = [
assert_eq!(matches.len(), 1);
assert_eq!(matches[0].1, captures);
}
#[test]
fn test_query_with_predicate_causing_oob_access() {
let language = get_language("rust");
let query = "(call_expression
function: (scoped_identifier
path: (scoped_identifier (identifier) @_regex (#any-of? @_regex \"Regex\" \"RegexBuilder\") .))
(#set! injection.language \"regex\"))";
Query::new(&language, query).unwrap();
}