Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to format file containing for (i in start..<start + count) #2925

Open
ikezedev opened this issue Jan 15, 2025 · 1 comment
Open

Fails to format file containing for (i in start..<start + count) #2925

ikezedev opened this issue Jan 15, 2025 · 1 comment

Comments

@ikezedev
Copy link

Expected Behavior

Should be able to format valid Kotlin for loop expression

for (i in start..<start + count) {
}

Observed Behavior

Ktlint failed to parse file

./gradlew :backend:ktlintFormat

The debug output was a bit too much, so could not put them here.

Steps to Reproduce

for (i in start..<start + count) {
}

Your Environment

  • Version of ktlint used: "11.3.2"
  • Relevant parts of the .editorconfig settings
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): Gradle plugin
  • Version of Gradle used (if applicable): 8.12
  • Operating System and version: Mac OS X 15.1.1 aarch64
@paul-dingemans
Copy link
Collaborator

I cannot reproduce a problem with a for loop like this. See output below:

 $ ktlint-1.5.0 --stdin
17:24:27.694 [main] INFO com.pinterest.ktlint.cli.internal.KtlintCommandLine -- Enable default patterns [**/*.kt, **/*.kts]
fun foo() {
    val start = 1
    val count = 10
    for (i in start..<start + count) {
    bar() // Wrongly indented
    }
}

fun bar() {}
<stdin>:5:1: Unexpected indentation (4) (should be 8) (standard:indent)

Summary error count (descending) by rule:
  standard:indent: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants