Skip to content

bug: forge fmt dropped statements for single-line **nested** if statements #13675

@quangloc99

Description

@quangloc99

Component

Other (please describe)

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

1.6.0-dev

What version of Foundryup are you on?

foundryup: 1.5.0

What command(s) is the bug in?

forge fmt

Operating System

None

Describe the bug

This is a follow up for the issue #13555 . I have made the fix in #13560 but I think this issue deserves its own report.

The issue #13555 shows that, previously forge fmt formats the following statement incorrectly.

// before forge fmt
if (condition) { execute(); execute(); }


// after forge fmt
if (condition) execute();
execute();

This got fixed, but the issue remains. Now for the nested if statement, forge fmt still formats incorrectly.

// before forge fmt
if (condition) if (condition) { execute(); execute(); }


// after forge fmt
if (condition) if (condition) execute();
execute();

More incorrectly-formatted tests can be seen in the commit daf10d2

Impact-wise, we rarely see nested if as above, but while (cond) if (cond) { ... } is more likely to be seen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions