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

Parsing fails on SIP-64 changes #4090

Open
asarkar opened this issue Dec 21, 2024 · 1 comment
Open

Parsing fails on SIP-64 changes #4090

asarkar opened this issue Dec 21, 2024 · 1 comment

Comments

@asarkar
Copy link

asarkar commented Dec 21, 2024

SIP-64 changes context bound and given clause syntaxes. It has been committed to Scala 3 codebase by the commit 14acdc0.

trait Display[A]:
  def display(value: A): String

final case class Cat(name: String, age: Int, color: String)
  
 given catDisplay: Display[Cat]:
    def display(cat: Cat): String =
      s"${cat.name} is a ${cat.age} year-old ${cat.color} cat."

Note the given definition ends with :, not with, as the latter has been deprecated and emits a warning:

Given member definitions starting with with are no longer supported; use {...} or : followed by newline instead

Using scalafmt 3.8.3 (even the latest v3.8.4-RC3), this fails.

[6] error: /path/to/Cat.scala: org.scalafmt.dynamic.exceptions.PositionExceptionImpl: /path/to/Cat.scala:6: error: [dialect scala3] `;` expected but `:` found
[6]   given catDisplay: Display[Cat]:
[6]                                 ^
[6] Caused by: /path/to/Cat.scala:6: error: [dialect scala3] `;` expected but `:` found
[6]   given catDisplay: Display[Cat]:
[6]                                 ^
[6] 	at org.scalafmt.Scalafmt$.$anonfun$doFormatOne$2(Scalafmt.scala:111)
[6] 	at scala.meta.parsers.Parsed.fold(Errors.scala:12)
[6] 	at scala.meta.parsers.Parsed.fold$(Errors.scala:10)
[6] 	at scala.meta.parsers.Parsed$Error.fold(Errors.scala:28)
[6] 	at org.scalafmt.Scalafmt$.doFormatOne(Scalafmt.scala:114)
[6] 	at org.scalafmt.Scalafmt$.doFormat(Scalafmt.scala:90)
[6] 	at org.scalafmt.Scalafmt$.$anonfun$formatCode$3(Scalafmt.scala:78)
@asarkar asarkar changed the title Fails on SIP-64 changes Parsing fails on SIP-64 changes Dec 21, 2024
@kitbellew
Copy link
Collaborator

duplicate of #4047.

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

No branches or pull requests

2 participants