Skip to content

R shell normalization has odd behavior in loop test(s) #1209

Open
@Ellpeck

Description

@Ellpeck

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnormalizeRelated to R-AST extraction and normalizationstatic slicingRelated to slicing the source code statically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions