pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.19k stars 505 forks source link

Multiline raw string literal in binary expression leads to uncompilable code #2577

Closed paul-dingemans closed 7 months ago

paul-dingemans commented 7 months ago

Given code below:

        logger.warn {
            """
            Axle version warning:
            =====================================================================================================

            """.trimIndent() +
                message.trimIndent() +
                """

                ====================================================================================================
                """.trimIndent()
        }

this is formatted by ktlint 1.2.0 as:

        logger.warn {
            """
            Axle version warning:
            =====================================================================================================

            """.trimIndent()
                +
                message.trimIndent() +
                """

                ====================================================================================================
                """.trimIndent()
        }

which can not be compiled succesfully

mgroth0 commented 7 months ago

Thank you for reporting this. Does it still happen in 1.2.1?

paul-dingemans commented 7 months ago

Yes, it was not resolved in 1.2.1. That was a kind of emergency fix. Although this one is annoying, it is easy to fix by the developer.