Menu

#553 Unexpected line break in lambda

closed-fixed
None
2023-08-29
2023-08-03
Nicola
No

An unexpected line break is added inside lambda.
Tested with 1TBS and K&R style.

Code block:

int main()
{
    const  int a = 10;

    const int b = [&] {
        if (a) {
            return 0;
        } else {
            return 10;
        }
    }();

    return b;
}

Astyle will add a line break between the if/else and {, resulting in:

    const int b = [&] {
        if (a)
        {
            return 0;
        } else
        {
            return 10;
        }
    }();

I've ran astyle with the following options:

$ ./astyle-3.4-x64/astyle.exe --version
Artistic Style Version 3.4

$ ./astyle-3.4-x64/astyle.exe --style=kr example_lambda.cpp 
1 Attachments

Discussion

  • André Simon

    André Simon - 2023-08-18

    Hi, thanks for reporting. There is a fix in the git repo which you can try til the next release.

     
  • André Simon

    André Simon - 2023-08-18
    • status: open --> open-fixed
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2023-08-29
    • status: open-fixed --> closed-fixed
     
  • André Simon

    André Simon - 2023-08-29

    Fixed in version 3.4.6

     
  • Nicola

    Nicola - 2023-08-29

    Thank you for the fix.
    It is working fine for me.

     

Log in to post a comment.

MongoDB Logo MongoDB