In this playground, the last statement is always ignored and not captured. Why is this?
https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImNwcCIsInF1ZXJ5IjoidXNpbmcgbmFtZXNwYWNlICRBOyIsInJld3JpdGUiOiJ1c2luZyBuYW1lc3BhY2UgZm9vOjokQTsiLCJjb25maWciOiJcbmlkOiB0ZXN0YmFzZV9pbml0aWFsaXplclxubGFuZ3VhZ2U6IENQUFxucnVsZTpcbiAgcGF0dGVybjpcbiAgICBzZWxlY3RvcjogY29tcG91bmRfc3RhdGVtZW50XG4gICAgY29udGV4dDogXCJBOjpBKCkgOiBmb28oKSB7ICQkJEJPRFlTVFVGRiB9XCJcbmZpeDogfC1cbiAge1xuICAgIGYoKTtcbiAgICAkJCRCT0RZU1RVRkY7XG4gIH0iLCJzb3VyY2UiOiJBOjpBKClcbiAgOiBiYXNlOjpDbGFzcyhhLCBiLCBjKSB7IFxuICAgICBhO1xuICAgICBiO1xuICAgICBjO1xuICB9In0=
Test C++ code:
A::A()
: base::Class(a, b, c) {
a;
b;
c;
}
Test rules:
id: testbase_initializer
language: CPP
rule:
pattern:
selector: compound_statement
context: "A::A() : foo() { $$$BODYSTUFF }"
fix: |-
{
f();
$$$BODYSTUFF;
}
Captured by BODYSTUFF
: a;b;
. But c;
is not in it. Why? For reference, the unreduced testcase is this:
id: testbase_initializer
language: CPP
rule:
pattern:
selector: compound_statement
context: "A::A() : foo() { $$$BODYSTUFF }"
follows:
kind: field_initializer_list
has:
pattern:
selector: field_initializer
context: "A::A() : TestBase($NAME, $DETAILS, $ID) { }"
fix: |-
{
setName($NAME);
setId($ID);
$$$BODYSTUFF
}
And it was intended to move part of the base class initializer into the body. But the fix always discarded the last body statement!