Description
The test
x <- 1
repeat {
x <- 2;
next;
x <- 3;
}
print(x)
as well as variations of it where repeat
is switched out with an infinite while loop or a very long for loop, both cause the R shell-based normalization to produce an unexpected AST, where the expression list's body is split into two separate expression lists for no apparent reason.
The mermaid diagram shows this issue based on the above code. The tree sitter mermaid shows a more intuitive interpretation of the code, where the expression list contains the three child nodes all on one level.
The test can be found in control-flow.test.ts.
I don't know why this happens, and at first glance, the R shell normalization seems wrong. The slices produced by both normalizations are the same, so in practice, this issue doesn't appear to be user-facing.