amnaredo / test

0 stars 0 forks source link

PPrint compile error with ADT #148

Open amnaredo opened 3 years ago

amnaredo commented 3 years ago
// build.sbt
scalaVersion := "2.11.7"

libraryDependencies += "com.lihaoyi" %% "fastparse" % "0.2.1"

libraryDependencies += "com.lihaoyi" %% "pprint" % "0.3.6"
// main.scala

sealed trait Expr extends Stmt
case class Num(s: Int) extends Expr
case class Parens(lhs: Expr, rhs: Expr) extends Expr
sealed trait Stmt
case class Print(s: Option[Expr]) extends Stmt
case class Class(name: String, stmts: Seq[Stmt]) extends Stmt
case class Def(name: String, stmts: Seq[Stmt]) extends Stmt

object Main{
  def main(args: Array[String]): Unit = {
    import pprint.pprintln
    pprintln(??? : Stmt)
  }
}
// output
[info] Compiling 1 Scala source to /Users/haoyi/Dropbox (Personal)/Workspace/demo/target/scala-2.11/classes...
[error] /Users/haoyi/Dropbox (Personal)/Workspace/demo/Main.scala:13: exception during macro expansion:
[error] scala.ScalaReflectionException: class scala.reflect.macros.Aliases in compiler mirror not found.
[error]     at scala.reflect.internal.Mirrors$RootsBase.staticClass(Mirrors.scala:123)
[error]     at scala.reflect.internal.Mirrors$RootsBase.staticClass(Mirrors.scala:22)
[error]     at pprint.Internals$LowerPriPPrint$$anon$1$$typecreator1$1.apply(PPrint.scala:394)
[error]     at scala.reflect.api.TypeTags$WeakTypeTagImpl.tpe$lzycompute(TypeTags.scala:232)
[error]     at scala.reflect.api.TypeTags$WeakTypeTagImpl.tpe(TypeTags.scala:232)
[error]     at scala.reflect.api.TypeTags$class.weakTypeOf(TypeTags.scala:335)
[error]     at scala.reflect.api.Universe.weakTypeOf(Universe.scala:61)
[error]     at derive.Derive.typeclassFor(Derive.scala:39)
[error]     at derive.Derive.derive$Derive$$implicited$1(Derive.scala:119)
[error]     at derive.Derive.deriveType(Derive.scala:121)
[error]     at derive.Derive.derive(Derive.scala:58)
[error]     at pprint.Internals$LowerPriPPrint$.liftedTree1$1(PPrint.scala:398)
[error]     at pprint.Internals$LowerPriPPrint$.FinalRepr(PPrint.scala:398)
[error]     pprintln(??? : Stmt)
[error]             ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 0 s, completed Oct 22, 2015 12:43:52 AM
10. Waiting for source changes... (press enter to interrupt)

ID: 116 Original Author: lihaoyi

amnaredo commented 3 years ago

Adding an explicit dependency on scala-reflect makes it go away

// build.sbt
scalaVersion := "2.11.7"

libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",

libraryDependencies += "com.lihaoyi" %% "pprint" % "0.3.6"
haoyi-mbp:test haoyi$ sbt run
[info] Loading global plugins from /Users/haoyi/.sbt/0.13/plugins
[info] Set current project to test (in build file:/Users/haoyi/Dropbox%20(Personal)/Workspace/test/)
[info] Updating {file:/Users/haoyi/Dropbox%20(Personal)/Workspace/test/}test...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/haoyi/Dropbox (Personal)/Workspace/test/target/scala-2.11/classes...
[info] Running Main
[error] (run-main-0) scala.NotImplementedError: an implementation is missing
scala.NotImplementedError: an implementation is missing
    at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
    at Main$.main(Main.scala:14)
    at Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
    at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.

GOK why...

Original Author: lihaoyi

amnaredo commented 3 years ago

Bug bankruptcy Original Author: lihaoyi