I found an example in the Arquero codebase where P42 makes buggy suggestions marked as "safe". The simplified snippet below involves a series of if-statement fallthroughs that can update the ast variable. P42 (correctly) notes that the assignment in the if(obj.window) branch can be replaced with a return statement. But afterward it continues suggesting similar replacements for other assignments which actually break the logic.
function test(obj) {
if (obj.expr) {
let ast;
if (obj.field === true) {
ast = obj.field;
} else if (obj.func === true) {
ast = obj.func;
}
if (ast) {
if (obj.desc) {
ast = { type: Descending, expr: ast };
}
if (obj.window) {
ast = { type: Window, expr: ast, ...obj.window };
}
return ast;
}
}
}
I found an example in the Arquero codebase where P42 makes buggy suggestions marked as "safe". The simplified snippet below involves a series of if-statement fallthroughs that can update the
ast
variable. P42 (correctly) notes that the assignment in theif(obj.window)
branch can be replaced with a return statement. But afterward it continues suggesting similar replacements for other assignments which actually break the logic.