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

Search state exploded error #3274

Closed
Arthurm1 opened this issue Jul 18, 2022 · 2 comments · Fixed by #3277
Closed

Search state exploded error #3274

Arthurm1 opened this issue Jul 18, 2022 · 2 comments · Fixed by #3277

Comments

@Arthurm1
Copy link

Configuration (required)

Please paste the contents of your .scalafmt.conf file here:

version = "3.5.8"
runner.dialect = scala213
maxColumn = 120
align.preset = some
align.stripMargin = true
docstrings.style = Asterisk
docstrings.wrap = no
assumeStandardLibraryStripMargin = true
newlines.inInterpolation = avoid

Command-line parameters (required)

scalafmt.bat FormatTest.scala

Steps

Given code like this:

package bar

import java.sql.ResultSet

class FormatTest {

  def createFoo(rs: ResultSet): Foo = {
    new Foo(
      rs.getDouble(1),
      rs.getDouble(2),
      rs.getDouble(3),
      rs.getDouble(4),
      rs.getDouble(5),
      rs.getDouble(6),
      rs.getDouble(7),
      rs.getDouble(8),
      rs.getDouble(9),
      rs.getDouble(10),
      rs.getDouble(11),
      rs.getDouble(12),
      rs.getDouble(13),
      rs.getDouble(14),
      rs.getDouble(15),
      rs.getDouble(16),
      rs.getDouble(17),
      rs.getDouble(18),
      rs.getDouble(19),
      rs.getDouble(20),
      rs.getDouble(21),
      rs.getDouble(22),
      rs.getDouble(23),
      rs.getDouble(24),
      rs.getDouble(25),
      rs.getDouble(26),
      rs.getDouble(27),
      rs.getDouble(28),
      rs.getDouble(29),
      rs.getDouble(30),
      rs.getDouble(31),
      rs.getDouble(32),
      rs.getDouble(33),
      rs.getDouble(34),
      rs.getDouble(35),
      rs.getDouble(36)
    )
  }
  class Foo(
      v1: Double,
      v2: Double,
      v3: Double,
      v4: Double,
      v5: Double,
      v6: Double,
      v7: Double,
      v8: Double,
      v9: Double,
      v10: Double,
      v11: Double,
      v12: Double,
      v13: Double,
      v14: Double,
      v15: Double,
      v16: Double,
      v17: Double,
      v18: Double,
      v19: Double,
      v20: Double,
      v21: Double,
      v22: Double,
      v23: Double,
      v24: Double,
      v25: Double,
      v26: Double,
      v27: Double,
      v28: Double,
      v29: Double,
      v30: Double,
      v31: Double,
      v32: Double,
      v33: Double,
      v34: Double,
      v35: Double,
      v36: Double
  )
}

Problem

Scalafmt formats code like this:

ERROR scalafmt: FormatTest.scalaorg.scalafmt.Error$SearchStateExploded: Search state exploded on ',∙rs[590:599]', line 26
	at org.scalafmt.internal.BestFirstSearch.shortestPath(BestFirstSearch.scala:179)
	at org.scalafmt.internal.BestFirstSearch.run$1(BestFirstSearch.scala:301)
	at org.scalafmt.internal.BestFirstSearch.getBestPath(BestFirstSearch.scala:302)
	at org.scalafmt.internal.BestFirstSearch$.apply(BestFirstSearch.scala:344)
	at org.scalafmt.Scalafmt$.$anonfun$doFormatOne$6(Scalafmt.scala:156)
	at scala.util.Try$.apply(Try.scala:210)
	at org.scalafmt.Scalafmt$.$anonfun$doFormatOne$4(Scalafmt.scala:156)
	at scala.meta.parsers.Parsed.fold(Errors.scala:12)
	at scala.meta.parsers.Parsed.fold$(Errors.scala:11)
	at scala.meta.parsers.Parsed$Success.fold(Errors.scala:26)
	at org.scalafmt.Scalafmt$.org$scalafmt$Scalafmt$$doFormatOne(Scalafmt.scala:152)
	at org.scalafmt.Scalafmt$.doFormat(Scalafmt.scala:126)
	at org.scalafmt.Scalafmt$.formatCodeWithStyle(Scalafmt.scala:91)
	at org.scalafmt.Scalafmt$.$anonfun$formatCode$3(Scalafmt.scala:78)
	at scala.util.Success.fold(Try.scala:281)
	at org.scalafmt.Scalafmt$.formatCode(Scalafmt.scala:78)
	at org.scalafmt.Scalafmt$.format(Scalafmt.scala:59)
	at org.scalafmt.Scalafmt.format(Scalafmt.scala)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:568)
	at org.scalafmt.dynamic.ScalafmtReflect.$anonfun$tryFormat$1(ScalafmtReflect.scala:121)
	at scala.util.Try$.apply(Try.scala:210)
	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:258)
	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.dynamic.ScalafmtDynamic.format(ScalafmtDynamic.scala:44)
	at scala.meta.internal.metals.FormattingProvider.runFormat(FormattingProvider.scala:140)
	at scala.meta.internal.metals.FormattingProvider.format(FormattingProvider.scala:116)
	at scala.meta.internal.metals.MetalsLanguageServer.$anonfun$formatting$1(MetalsLanguageServer.scala:1552)
	at scala.meta.internal.metals.CancelTokens$.future(CancelTokens.scala:38)
	at scala.meta.internal.metals.MetalsLanguageServer.formatting(MetalsLanguageServer.scala:1547)
	at jdk.internal.reflect.GeneratedMethodAccessor30.invoke(null)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.TracingMessageConsumer.consume(TracingMessageConsumer.java:114)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.lang.Thread.run(Thread.java:833)

Expectation

I would like the formatted output to not throw an exception

Workaround

I've found that by reducing the number of parameters by 1 then it works.
For now I've used // format: off

@kitbellew
Copy link
Collaborator

what about Foo but without new?

@Arthurm1
Copy link
Author

@kitbellew although new Foo blew with a threw, Foo without new formats true. Thanks - I'll use apply

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