Skip to content

Missing support for name-based destructuring #629

Closed

Description

@Yqloss

Tested with ktfmt IDEA plugin 1.3.0.63.

data class D(val a: Int, val b: Int)
val d = D(1, 2)

Successes

Save the file and see the spaces removed.

val (a, b         ) = d // experimental name-based destructuring syntax, which looks the same as position-based in stable kotlin

Failures

Ktfmt is kind of stuck (IDEA shows "Running ktfmt..." but it doesn't complete) while formatting the file, which timeouts after 30 seconds on IDEA. The spaces are not removed.

val [a, b         ] = d // experimental position-based destructuring syntax
val (a, x = b         ) = d // experimental name-based destructuring syntax with renaming

Build Script

// build.gradle.kts

kotlin {
  jvmToolchain(21)
  compilerOptions {
    jvmTarget = JvmTarget.JVM_21
    freeCompilerArgs.addAll(
      "-Xname-based-destructuring=complete",
    )
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions