Skip to content

interspersed autofix of multiple expressions on same line #3577

@gordonwoodhull

Description

@gordonwoodhull

Similar to #3388, if fixing multiple expressions in the same line, the autofixes can get mixed up and duplicated, resulting in garbled code.

Here is the repro: https://semgrep.dev/s/gordonwoodhull:wrap-strings

On semgrep.dev it produces the correct individual suggestions. However, when running semgrep 0.59 on the command line with --autofix, it looks like it confuses the output positions between the two fixes.

The rule attempts to replace the expression pattern (String $S) with the fix wrap($S).

On input

        return "a" + "b";

it produces the output

        return wrap("wrap("b") + "b";

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions