scalacenter / scala-syntax

Scalameta pretty printer for better Scalafix refactorings
Apache License 2.0
17 stars 6 forks source link

Complete IdempotentAstTest #30

Open MasseGuillaume opened 6 years ago

MasseGuillaume commented 6 years ago

2 failures remaining:

val dq = '"'
val tq = s"${dq}${dq}${dq}"

// scalameta#1384
check(s"""
  val b = ${tq}
             \\u005Cu0041${tq}
""")

// scalameta#1385
check("-0.0d") 

https://github.com/scalameta/scalameta/issues/1385 https://github.com/scalameta/scalameta/issues/1384

olafurpg commented 6 years ago

Unhandled case

  check("if (a) (if (b) c) else d")
  java.lang.RuntimeException: AST changed
    obtained: if (a) if (b) c else d
    expected: if (a) (if (b) c) else d

This doesn't seem to be handled by precedence rules. Without the parens around if (b) c it parses differently

ollie-scalafmt@ q"if (a) if (b) c else d"
res4: Term.If = Term.If(Term.Name("a"), Term.If(Term.Name("b"), Term.Name("c"), Term.Name("d")), Lit.Unit(()))

ollie-scalafmt@ q"if (a) (if (b) c) else d"
res5: Term.If = Term.If(Term.Name("a"), Term.If(Term.Name("b"), Term.Name("c"), Lit.Unit(())), Term.Name("d"))
olafurpg commented 6 years ago

Discovered by @japgolly in https://github.com/scalameta/scalafmt/pull/1122