diff --git a/crates/cli/src/tests/query_test.rs b/crates/cli/src/tests/query_test.rs index e70dd26b..b59a1f42 100644 --- a/crates/cli/src/tests/query_test.rs +++ b/crates/cli/src/tests/query_test.rs @@ -238,6 +238,20 @@ fn test_query_errors_on_invalid_syntax() { ] .join("\n") ); + assert_eq!( + Query::new(&language, "(statement / export_statement)").unwrap_err(), + QueryError { + row: 0, + offset: 11, + column: 11, + kind: QueryErrorKind::Syntax, + message: [ + "(statement / export_statement)", // + " ^" + ] + .join("\n") + } + ); }); } diff --git a/lib/src/query.c b/lib/src/query.c index 302e3f59..56e32873 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -2452,8 +2452,6 @@ static TSQueryError ts_query__parse_pattern( step->is_named = true; } - stream_skip_whitespace(stream); - // Parse a supertype symbol if (stream->next == '/') { if (!step->supertype_symbol) { @@ -2516,10 +2514,10 @@ static TSQueryError ts_query__parse_pattern( return TSQueryErrorStructure; } } - - stream_skip_whitespace(stream); } + stream_skip_whitespace(stream); + // Parse the child patterns bool child_is_immediate = false; uint16_t last_child_step_index = 0;