File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -5171,3 +5171,20 @@ fn test_query_compiler_oob_access() {
5171
5171
// UBSAN should not report any OOB access
5172
5172
assert ! ( Query :: new( & language, "(package_declaration _ (_) @name _)" ) . is_ok( ) ) ;
5173
5173
}
5174
+
5175
+ #[ test]
5176
+ fn test_query_wildcard_with_immediate_first_child ( ) {
5177
+ let language = get_language ( "javascript" ) ;
5178
+ let query = Query :: new ( & language, "(_ . (identifier) @firstChild)" ) . unwrap ( ) ;
5179
+ let source = "function name(one, two, three) { }" ;
5180
+
5181
+ assert_query_matches (
5182
+ & language,
5183
+ & query,
5184
+ source,
5185
+ & [
5186
+ ( 0 , vec ! [ ( "firstChild" , "name" ) ] ) ,
5187
+ ( 0 , vec ! [ ( "firstChild" , "one" ) ] ) ,
5188
+ ] ,
5189
+ ) ;
5190
+ }
Original file line number Diff line number Diff line change @@ -2740,7 +2740,7 @@ TSQuery *ts_query_new(
2740
2740
// there is a parent node, and capture it if necessary.
2741
2741
if (step -> symbol == WILDCARD_SYMBOL && step -> depth == 0 && !step -> field ) {
2742
2742
QueryStep * second_step = & self -> steps .contents [start_step_index + 1 ];
2743
- if (second_step -> symbol != WILDCARD_SYMBOL && second_step -> depth == 1 ) {
2743
+ if (second_step -> symbol != WILDCARD_SYMBOL && second_step -> depth == 1 && ! second_step -> is_immediate ) {
2744
2744
wildcard_root_alternative_index = step -> alternative_index ;
2745
2745
start_step_index += 1 ;
2746
2746
step = second_step ;
You can’t perform that action at this time.
0 commit comments