Code-Inspect / flowr

A program slicer and dataflow analyzer for the R programming language.
https://github.com/Code-Inspect/flowr/wiki
GNU General Public License v3.0
14 stars 2 forks source link

Breaking in `while` and `for` is ignored in slice #804

Open Ellpeck opened 1 month ago

Ellpeck commented 1 month ago
assertSliced(label('Break immediately', [...caps, 'name-normal', ...OperatorDatabase['<-'].capabilities, 'numbers', 'semicolons', 'newlines', 'break', 'unnamed-arguments']),
                    shell, `x <- 1
${loop} {
   x <- 2;
   break
}
print(x)`, ['6@x'], 'x <- 2\nx')

with loop set to while(TRUE) or for(i in 1:100) slices incorrectly

800

Ellpeck commented 1 month ago

Also true for related tests, see https://github.com/Code-Inspect/flowr/pull/800/commits/31727a89972b3b2eac73555d44f3cdf57dafa296

EagleoutIce commented 1 month ago

For now, we assume this to be correct as we do not have to be smart enough to detect, that the loop is always executed only once. This is up to abstract interpretation to figure out.