You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> scalafmt <path>/A.scala
org.scalafmt.cli.FailedToFormat: <path>/A.scala
Caused by: org.scalafmt.Error$PreciseIncomplete: <path>/A.scala:4: error: Unable to format file due to bug in scalafmt
def f(a: (
^
at org.scalafmt.Scalafmt$.$anonfun$doFormatOne$6(Scalafmt.scala:123)
at scala.util.Success.flatMap(Try.scala:266)
at org.scalafmt.Scalafmt$.$anonfun$doFormatOne$3(Scalafmt.scala:118)
at scala.meta.parsers.Parsed.fold(Errors.scala:11)
at scala.meta.parsers.Parsed.fold$(Errors.scala:10)
at scala.meta.parsers.Parsed$Success.fold(Errors.scala:25)
at org.scalafmt.Scalafmt$.doFormatOne(Scalafmt.scala:114)
at org.scalafmt.Scalafmt$.doFormat(Scalafmt.scala:90)
at org.scalafmt.Scalafmt$.$anonfun$formatCode$3(Scalafmt.scala:78)
at scala.util.Success.fold(Try.scala:289)
at org.scalafmt.Scalafmt$.formatCode(Scalafmt.scala:78)
at org.scalafmt.Scalafmt$.format(Scalafmt.scala:57)
at org.scalafmt.Scalafmt.format(Scalafmt.scala)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.scalafmt.dynamic.ScalafmtReflect.$anonfun$tryFormat$1(ScalafmtReflect.scala:121)
at scala.util.Try$.apply(Try.scala:217)
at org.scalafmt.dynamic.ScalafmtReflect.tryFormat(ScalafmtReflect.scala:117)
at org.scalafmt.dynamic.ScalafmtReflectConfig.tryFormat(ScalafmtReflectConfig.scala:95)
at org.scalafmt.dynamic.ScalafmtDynamicSession.$anonfun$tryForceFormat$1(ScalafmtDynamicSession.scala:49)
at scala.util.Success.flatMap(Try.scala:266)
at org.scalafmt.dynamic.ScalafmtDynamicSession.tryForceFormat(ScalafmtDynamicSession.scala:49)
at org.scalafmt.dynamic.ScalafmtDynamicSession.tryFormat(ScalafmtDynamicSession.scala:36)
at org.scalafmt.dynamic.ScalafmtDynamicSession.format(ScalafmtDynamicSession.scala:18)
at org.scalafmt.cli.ScalafmtDynamicRunner$.handleFile(ScalafmtDynamicRunner.scala:74)
at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$7(ScalafmtDynamicRunner.scala:48)
at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$7$adapted(ScalafmtDynamicRunner.scala:46)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1303)
at scala.collection.parallel.ParIterableLike$Foreach.leaf(ParIterableLike.scala:938)
at scala.collection.parallel.Task.$anonfun$tryLeaf$1(Tasks.scala:52)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.util.control.Breaks$$anon$1.catchBreak(Breaks.scala:97)
at scala.collection.parallel.Task.tryLeaf(Tasks.scala:55)
at scala.collection.parallel.Task.tryLeaf$(Tasks.scala:49)
at scala.collection.parallel.ParIterableLike$Foreach.tryLeaf(ParIterableLike.scala:935)
at scala.collection.parallel.AdaptiveWorkStealingTasks$AWSTWrappedTask.compute(Tasks.scala:152)
at scala.collection.parallel.AdaptiveWorkStealingTasks$AWSTWrappedTask.compute$(Tasks.scala:148)
at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$AWSFJTWrappedTask.compute(Tasks.scala:304)
at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Expectation
Workaround
If either of these lines are removed, it will not reproduce
> scalafmt <path>/A.scala
org.scalafmt.cli.FailedToFormat: <path>/A.scala
Caused by: org.scalafmt.Error$PreciseIncomplete: <path>/A.scala:10: error: Unable to format file due to bug in scalafmt
(
^
at org.scalafmt.Scalafmt$.$anonfun$doFormatOne$6(Scalafmt.scala:123)
at scala.util.Success.flatMap(Try.scala:266)
at org.scalafmt.Scalafmt$.$anonfun$doFormatOne$3(Scalafmt.scala:118)
at scala.meta.parsers.Parsed.fold(Errors.scala:11)
at scala.meta.parsers.Parsed.fold$(Errors.scala:10)
at scala.meta.parsers.Parsed$Success.fold(Errors.scala:25)
at org.scalafmt.Scalafmt$.doFormatOne(Scalafmt.scala:114)
at org.scalafmt.Scalafmt$.doFormat(Scalafmt.scala:90)
at org.scalafmt.Scalafmt$.$anonfun$formatCode$3(Scalafmt.scala:78)
at scala.util.Success.fold(Try.scala:289)
at org.scalafmt.Scalafmt$.formatCode(Scalafmt.scala:78)
at org.scalafmt.Scalafmt$.format(Scalafmt.scala:57)
at org.scalafmt.Scalafmt.format(Scalafmt.scala)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.scalafmt.dynamic.ScalafmtReflect.$anonfun$tryFormat$1(ScalafmtReflect.scala:121)
at scala.util.Try$.apply(Try.scala:217)
at org.scalafmt.dynamic.ScalafmtReflect.tryFormat(ScalafmtReflect.scala:117)
at org.scalafmt.dynamic.ScalafmtReflectConfig.tryFormat(ScalafmtReflectConfig.scala:95)
at org.scalafmt.dynamic.ScalafmtDynamicSession.$anonfun$tryForceFormat$1(ScalafmtDynamicSession.scala:49)
at scala.util.Success.flatMap(Try.scala:266)
at org.scalafmt.dynamic.ScalafmtDynamicSession.tryForceFormat(ScalafmtDynamicSession.scala:49)
at org.scalafmt.dynamic.ScalafmtDynamicSession.tryFormat(ScalafmtDynamicSession.scala:36)
at org.scalafmt.dynamic.ScalafmtDynamicSession.format(ScalafmtDynamicSession.scala:18)
at org.scalafmt.cli.ScalafmtDynamicRunner$.handleFile(ScalafmtDynamicRunner.scala:74)
at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$7(ScalafmtDynamicRunner.scala:48)
at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$7$adapted(ScalafmtDynamicRunner.scala:46)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1303)
at scala.collection.parallel.ParIterableLike$Foreach.leaf(ParIterableLike.scala:938)
at scala.collection.parallel.Task.$anonfun$tryLeaf$1(Tasks.scala:52)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.util.control.Breaks$$anon$1.catchBreak(Breaks.scala:97)
at scala.collection.parallel.Task.tryLeaf(Tasks.scala:55)
at scala.collection.parallel.Task.tryLeaf$(Tasks.scala:49)
at scala.collection.parallel.ParIterableLike$Foreach.tryLeaf(ParIterableLike.scala:935)
at scala.collection.parallel.AdaptiveWorkStealingTasks$AWSTWrappedTask.compute(Tasks.scala:152)
at scala.collection.parallel.AdaptiveWorkStealingTasks$AWSTWrappedTask.compute$(Tasks.scala:148)
at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$AWSFJTWrappedTask.compute(Tasks.scala:304)
at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Please note that this/these problem was not caused by intentionally giving pathological code to cause errors, but was accidental due to the corrupted formatting that existed in our project.
The text was updated successfully, but these errors were encountered:
Configuration (required)
Command-line parameters (required)
When I run scalafmt via CLI like this:
scalafmt A.scala
Steps
Given code like this:
Problem
Scalafmt formats code like this:
Expectation
Workaround
If either of these lines are removed, it will not reproduce
Notes
This code also raises an error.
Please note that this/these problem was not caused by intentionally giving pathological code to cause errors, but was accidental due to the corrupted formatting that existed in our project.
The text was updated successfully, but these errors were encountered: