query: Fix detection of repeated field names

Fixes #790
This commit is contained in:
Max Brunsfeld 2020-11-02 14:07:39 -08:00
parent 3497f34dd7
commit 99cd283e39
2 changed files with 36 additions and 5 deletions

View file

@ -1835,6 +1835,33 @@ fn test_query_matches_with_no_captures() {
});
}
#[test]
fn test_query_matches_with_repeated_fields() {
allocations::record(|| {
let language = get_language("c");
let query = Query::new(
language,
"(field_declaration declarator: (field_identifier) @field)",
)
.unwrap();
assert_query_matches(
language,
&query,
"
struct S {
int a, b, c;
}
",
&[
(0, vec![("field", "a")]),
(0, vec![("field", "b")]),
(0, vec![("field", "c")]),
],
);
});
}
#[test]
fn test_query_captures_basic() {
allocations::record(|| {