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

Produces Non-Compiling Code with implicit keyword after colon #3763

Closed
dallinhuff opened this issue Jan 20, 2024 · 2 comments · Fixed by #3782
Closed

Produces Non-Compiling Code with implicit keyword after colon #3763

dallinhuff opened this issue Jan 20, 2024 · 2 comments · Fixed by #3782

Comments

@dallinhuff
Copy link

Configuration

version = 3.7.17
runner.dialect = scala3

Command-line parameters

When I run scalafmt via CLI like this: scalafmt .

Steps

Given code like this:

def runJs: CancelableFuture[A] =
  Unsafe.unsafe:
    implicit unsafe =>
      Runtime.default.unsafe
        .runToFuture(zio.provide(BackendClientLive.configuredLayer))

Problem

Scalafmt formats code like this:

def runJs: CancelableFuture[A] =
  Unsafe.unsafe: implicit unsafe =>
    Runtime.default.unsafe
      .runToFuture(zio.provide(BackendClientLive.configuredLayer))

The formatted code no longer compiles because the next token after the colon in Unsafe.unsafe: needs to be either a newline/significant indentation or an identifier. The implicit keyword is neither of these.

Expectation

I would like the formatted output to look like this, since it compiles:

def runJs: CancelableFuture[A] =
  Unsafe.unsafe:
    implicit unsafe =>
      Runtime.default.unsafe
        .runToFuture(zio.provide(BackendClientLive.configuredLayer))
@kitbellew
Copy link
Collaborator

@dallinhuff could you please show which part of syntax allows implicit (or anything other than erased) in ColonArgument?

@dallinhuff
Copy link
Author

@kitbellew Looks like this might have been an issue with someone (manually) rewriting some old Scala 2 to use fewerBraces. Rewriting implicit id => ... as a context function id ?=> ... seems to fix the problem and scalafmt handles this as expected.

def runJs: CancelableFuture[A] =
  Unsafe.unsafe: unsafe ?=>
    Runtime.default.unsafe
      .runToFuture(zio.provide(BackendClientLive.configuredLayer))

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

Successfully merging a pull request may close this issue.

2 participants