Skip to content

Commit

Permalink
Fix nested bindings in queries (#927)
Browse files Browse the repository at this point in the history
Cherry-picked from
bb92384.
We need this for 0.14 to allow for more interesting queries for
NomicFoundation/hardhat-vscode#547.

Co-authored-by: Antony Blakey <antony@nomic.foundation>
  • Loading branch information
Xanewok and AntonyBlakey authored Apr 8, 2024
1 parent 5cf6b7f commit e336462
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/codegen/parser/runtime/src/query/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl Combinator for BindingCombinator {
.entry(self.matcher.name.clone())
.or_default()
.push(self.cursor.clone());
self.child.accumulate_bindings(bindings);
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions crates/testlang/outputs/cargo/tests/src/query/engine_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,14 @@ fn test_optional() {
},
);
}

#[test]
fn test_nested() {
run_query_test(
&common_test_tree(),
"@root [TreeNode ... @z [DelimitedIdentifier] [_] ]",
query_results! {
{root: ["ABCDE"], z: ["C"]}
},
);
}

0 comments on commit e336462

Please sign in to comment.