Skip to content

Instantly share code, notes, and snippets.

@olafurpg
Last active April 15, 2016 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olafurpg/203ffbd16cd740acb996 to your computer and use it in GitHub Desktop.
Save olafurpg/203ffbd16cd740acb996 to your computer and use it in GitHub Desktop.
Remaining bugs in scala.meta parser
ollie-scalafmt@ """foo(1, b = true, js = xs: _*)""".parse[Stat]
scala.meta.parsers.common.ParseException: ) expected but identifier found at 27..28
ollie-scalafmt@ """case a: Array[_] ⇒ format(t, (a map (_.asInstanceOf[AnyRef]): _*))""".parse[Case]
scala.meta.parsers.common.ParseException: ) expected but identifier found at 63..64
ollie-scalafmt@ """(new t1785)[Int](1)""".parse[Stat]
scala.meta.parsers.common.ParseException: ; expected but [ found at 11..12
ollie-scalafmt@ """package a
{
package b
{
object A
{
private[a] def x = 3
}
}
}""".parse[Stat]
scala.meta.parsers.common.ParseException: { expected but \n found at 9..10
// Apply method with type param
ollie-scalafmt@ """assert((params ++ params2)[TestParam] == TestParam(999))""".parse[Stat]
scala.meta.parsers.common.ParseException: ) expected but [ found at 26..27
// Context
scala> class Foo { def apply[T]: Int = 5 }
defined class Foo
scala> val v = new Foo
v: Foo = Foo@604c9c17
scala> v[String]
res0: Int = 5
scala> v[String] == 5
res1: Boolean = true
ollie-scalafmt@ """type Y[A, B] = A * B""".parse[Stat]
scala.meta.parsers.common.ParseException: ; expected but identifier found at 17..18
ollie-scalafmt@ """trait Inner <: { val x : Int = 3 }""".parse[Stat]
scala.meta.parsers.common.ParseException: ; expected but <: found at 12..14
ollie-scalafmt@ """ spawn {
var v: Int = _;
while(c<n) { c=c+1; v = buffer.get; }
cDone set true;
}""".parse[Stat]
scala.meta.parsers.common.ParseException: is not a valid block statement at 24..38
ollie-scalafmt@ """object Test extends { type T = Int } with App""".parse[Stat]
scala.meta.parsers.common.ParseException: early type members are not allowed any longer. Move them to the regular body: the semantics are the same. at 22..34
@paulp
Copy link

paulp commented Apr 15, 2016

trait Inner <: { val x : Int = 3 }

It should be seen as a bug in scalac that this not only parses, but compiles! Using <: on traits is a stupidity of the parser left over from some abortive attempt to add virtual classes.

a.scala:2: error: only declarations allowed here
  type Bip = { val x : Int = 3 }
                   ^
one error found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment