scalafix icon indicating copy to clipboard operation
scalafix copied to clipboard

empty line in for comprehension sometime doesn't not compile since v0.13.0

Open strokyl opened this issue 1 year ago • 4 comments
trafficstars

After the update to v0.13.0, when running scalafix, we have a lot of compilation errors with the following message:

error: `}` expected but `<-` found

Normal scala compilation works fine. The only common pattern I found where this occurs is that an empty line always precedes the problematic line. But where it gets weird is that I have some for comprehension with empty lines that compile fine with scalafix.

Here is an example:

    for {
      maybeOrg     <- findOrganization
      organization <- ZIO.succeed(maybeOrg).someOrElseZIO(createOrganization(consoleConfig.organization))

      (maybeAdminUser, otherUsers) <-
        syncLocalUsers(
          adminUserConfig = consoleConfig.admin,
          otherUserConfigs = consoleConfig.auth.map(_.localUsers).getOrElse(Nil),
          organizationId = organization.id
        )

      _                            <- maybeAdminUser
                                        .map(adminUser => addUserToOrganizationService.addUserToOrganization(adminUser.email, organization.id, isAdmin = true))
                                        .getOrElse(ZIO.unit)
      _                            <- ZIO.foreachDiscard(otherUsers)(user =>
                                        addUserToOrganizationService.addUserToOrganization(user.email, organization.id, isAdmin = false)
                                      )

      _ <- maybeAdminUser.map(adminUser => initializeClusters(organization, adminUser)).getOrElse(ZIO.unit)

    } yield ()

the scala error is:

[info] Running scalafix on 1 Scala sources (incremental)
[error] /home/lduzan/code/console-plus-2/modules/admin/admin/src/main/scala/io/conduktor/admin/service/OnPremInitializationService.scala:44:36: error: `}` expected but `<-` found
[error]       _                            <- maybeAdminUser
[error]                                    ^^
[error] (Compile / scalafix) scalafix.sbt.ScalafixFailed: ParseError
[error] Total time: 0 s, completed 30 sept. 2024, 10:20:26

and removing the empty line before maybeAdminUser fixes the issue.

scala version: 3.5.1 scalafix version: 0.13.0 sbt version: 1.10.2

strokyl avatar Sep 30 '24 08:09 strokyl