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

cats-effect: Unable to format file due to bug in scalafmt #1714

Closed
rossabaker opened this issue Feb 17, 2020 · 8 comments · Fixed by #1719
Closed

cats-effect: Unable to format file due to bug in scalafmt #1714

rossabaker opened this issue Feb 17, 2020 · 8 comments · Fixed by #1719

Comments

@rossabaker
Copy link

This template is a guideline, not a strict requirement.

  • Version: 2.4.1
  • Integration: sbt-scalafmt
  • Configuration:
version = 2.4.1
align = none
align.openParenCallSite = true
align.openParenDefnSite = true
maxColumn = 120
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
danglingParentheses = true
rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, SortModifiers]
docstrings = JavaDoc
lineEndings=preserve

Steps

Given code like this:

  testAsync("Resource.make is equivalent to a partially applied bracket") { implicit ec =>
    check { (acquire: IO[String], release: String => IO[Unit], f: String => IO[String]) =>
      acquire.bracket(f)(release) <-> Resource.make(acquire)(release).use(f)
    }
  }

When I run scalafmt like this:

sbt lawsJVM/scalafmtAll

Problem

Scalafmt fails:

[error] /home/ross/src/cats-effect/laws/shared/src/test/scala/cats/effect/ResourceTests.scala:56: error: Unable to format file due to bug in scalafmt
[error]       acquire.bracket(f)(release) <-> Resource.make(acquire)(release).use(f)
[error]                                 ^: /home/ross/src/cats-effect/laws/shared/src/test/scala/cats/effect/ResourceTests.scala
[error] (lawsJVM / Test / scalafmt) /home/ross/src/cats-effect/laws/shared/src/test/scala/cats/effect/ResourceTests.scala:56: error: Unable to format file due to bug in scalafmt
[error]       acquire.bracket(f)(release) <-> Resource.make(acquire)(release).use(f)
[error]                                 ^: /home/ross/src/cats-effect/laws/shared/src/test/scala/cats/effect/ResourceTests.scala

Expectation

scalafmt succeeds and the output still compiles

Workaround

Not upgrading to 2.4.1.

Notes

Similar to #1599, but not the same as what @larsrh reported for cats-effect on 2.4.0.

@kitbellew
Copy link
Collaborator

Similar to #1599, but not the same as what @larsrh reported for cats-effect on 2.4.0.

what was the problem in 2.4.0? i don't think i have seen that report.

@larsrh
Copy link

larsrh commented Feb 17, 2020

@kitbellew See #1599 (comment)

@kitbellew
Copy link
Collaborator

@kitbellew See #1599 (comment)

@larsrh is there a code example which can be used to reproduce the problem?

@larsrh
Copy link

larsrh commented Feb 17, 2020 via email

@kitbellew
Copy link
Collaborator

Yes, you can run scalafmtAll on the PR.

of course.

@kitbellew kitbellew reopened this Feb 17, 2020
kitbellew added a commit to kitbellew/scalafmt that referenced this issue Feb 17, 2020
kitbellew added a commit to kitbellew/scalafmt that referenced this issue Feb 17, 2020
When lambda parameters are themselves functions and contained arrows in
their type definitions, the code would locate the wrong arrow and then
fail to break after it as no such break is defined in any rules.

Fixes scalameta#1714.
kitbellew added a commit to kitbellew/scalafmt that referenced this issue Feb 17, 2020
When lambda parameters are themselves functions and contained arrows in
their type definitions, the code would locate the wrong arrow and then
fail to break after it as no such break is defined in any rules.

Fixes scalameta#1714.
kitbellew added a commit that referenced this issue Feb 17, 2020
When lambda parameters are themselves functions and contained arrows in
their type definitions, the code would locate the wrong arrow and then
fail to break after it as no such break is defined in any rules.

Fixes #1714.
@kitbellew
Copy link
Collaborator

@kitbellew See #1599 (comment)

@larsrh is there a code example which can be used to reproduce the problem?

@larsrh please see if your problem is fixed by #1719.

also, it would make it easier in the future if you could share your problems with the tool by submitting a new issue with the configuration and exact steps to reproduce.

@rossabaker
Copy link
Author

I can test. Are snapshots published anywhere? I checked Sonatype, and don't see any past 2.3.1. Thanks!

@kitbellew
Copy link
Collaborator

I can test. Are snapshots published anywhere? I checked Sonatype, and don't see any past 2.3.1.

honestly, i don't know. i build locally and run this:

v=2.4.1
# build
sbt publishLocal
# turn into a binary
coursier bootstrap org.scalameta:scalafmt-cli_2.13:$v-SNAPSHOT \
  -f -r sonatype:snapshots \
  -o scalafmt.new --standalone --main org.scalafmt.cli.Cli
# run
./scalafmt.new --test

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.

3 participants