Menu

#555 Unexpected indent in immediately called lambda

closed-fixed
None
2025-11-13
2023-08-30
No

When used indent-lambda, the Indentation of lambda containing if-else is wrong.

code:

void func()
{
    // if-else in immediately called lambda
    int c = [] {
        if (true) {
            return 1;
        } else {
            return 2;
        }
    }();
}

I ran astye as follows:

$ astyle --version
Artistic Style Version 3.4.6
$ astyle --options=none --style=1tbs --indent-lambda indent-lambda.cpp

becomes:

@@ -5,8 +5,8 @@ void func()
     int c = [] {
         if (true) {
             return 1;

-        } else {
-            return 2;
-        }
-    }();
+    } else {
+        return 2;
+    }
+}();
 }
1 Attachments

Discussion

  • André Simon

    André Simon - 2023-09-01

    Yes, that is why you need to apply --indent-lambdaas opt-in because this case is not covered ;)

     
  • André Simon

    André Simon - 2025-07-22

    Hi, please try again with 3.6.10

     
  • André Simon

    André Simon - 2025-07-22
    • status: open --> open-fixed
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2025-11-13
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB