Skip to content

Commit

Permalink
Fix query bugs revealed by randomized tests
Browse files Browse the repository at this point in the history
* Fix bugs related to named wildcard patterns vs regular wildcard patterns.
* Fix handling of extra nodes during query analysis. Previously, the
expected child_index was updated incorrectly after an extra node,
leading to false "impossible pattern" errors.
* Refine logic for avoiding unnecessary state-splitting due to fallible steps.
Compute *two* different analysis results related to step fallibility:
  * `root_pattern_guaranteed` which, like before, summarizes whether the
    entire pattern is guaranteed to match once this step is reached.
  * `parent_pattern_guaranteed` - which just indicates whether the
    immediate parent pattern is guaranteed. This is now used when
    deciding whether it's necessary to split a match state.
  • Loading branch information
maxbrunsfeld committed Nov 21, 2021
1 parent fea3eca commit 54f97b2
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 112 deletions.
15 changes: 15 additions & 0 deletions cli/src/tests/query_test.rs
Expand Up @@ -3770,6 +3770,21 @@ fn test_query_is_pattern_guaranteed_at_step() {
("(heredoc_end)", true),
],
},
Row {
description: "multiple extra nodes",
language: get_language("rust"),
pattern: r#"
(call_expression
(line_comment) @a
(line_comment) @b
(arguments))
"#,
results_by_substring: &[
("(line_comment) @a", false),
("(line_comment) @b", false),
("(arguments)", true),
],
},
];

allocations::record(|| {
Expand Down

0 comments on commit 54f97b2

Please sign in to comment.