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

Diverging implicit pprint with Nil or None with default-predef.scala #313

Closed
lihaoyi opened this Issue Dec 23, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@lihaoyi
Owner

lihaoyi commented Dec 23, 2015

It seems to work fine when my predef is commented out

haoyi-mbp:Ammonite haoyi$ cat ~/.ammonite/predef.scala
/*load.ivy("com.lihaoyi" %% "ammonite-shell" % ammonite.Constants.version)
@
val shellSession = ammonite.shell.ShellSession()
import shellSession._
import ammonite.shell.PPrints._
import ammonite.ops._
import ammonite.shell._
ammonite.shell.Configure(repl, wd)*/
haoyi-mbp:Ammonite haoyi$ ~/amm
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_25)
@ None; Nil
res0_0: None.type = None
res0_1: collection.immutable.Nil.type = List()

But if it's in place, it blows up

haoyi-mbp:Ammonite haoyi$ cat ~/.ammonite/predef.scala
load.ivy("com.lihaoyi" %% "ammonite-shell" % ammonite.Constants.version)
@
val shellSession = ammonite.shell.ShellSession()
import shellSession._
import ammonite.shell.PPrints._
import ammonite.ops._
import ammonite.shell._
ammonite.shell.Configure(repl, wd)
haoyi-mbp:Ammonite haoyi$ ~/amm
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_25)
haoyi-Ammonite@ None; Nil
Compilation Failed
Main.scala:154: diverging implicit expansion for type pprint.PPrinter[A]
starting with method pathRepr in object PPrints
              .print(res0_0, res0_0, "res0_0", scala.None)
                    ^

Clearly some implicit in the default predef is messing with things.

@lihaoyi lihaoyi added the bug label Dec 23, 2015

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Dec 23, 2015

Here's a smaller repro, with no predef

haoyi-mbp:Ammonite haoyi$ ~/amm
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_25)
@ None
res0: None.type = None
@ implicit def foo: pprint.PPrinter[java.io.File] = ???
defined function foo
@ None
Compilation Failed
Main.scala:49: diverging implicit expansion for type pprint.PPrinter[A]
starting with method foo in object cmd1
              .print(res2, res2, "res2", scala.None)
                    ^

wtf?

@winitzki

This comment has been minimized.

Contributor

winitzki commented Sep 7, 2016

Another comment: the problem occurs only when None is not explicitly typed (of type None.type).

@ val x : Option[Int] = None
x: Option[Int] = None
@ x
res1: Option[Int] = None
@ None
cmd2.sc:8: diverging implicit expansion for type pprint.PPrinter[A]
starting with method lsSeqRepr in object PPrints
            .print(res2, res2, "res2", _root_.scala.None)
                  ^
Compilation Failed
@DavidPerezIngeniero

This comment has been minimized.

DavidPerezIngeniero commented Nov 8, 2016

I'm having the same error!

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented May 17, 2017

Should be fixed in 2d78e1f, which uses the new version of pprint which no longer uses macros/implicits

@lihaoyi lihaoyi closed this May 17, 2017

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