Skip to content

Shapeless' narrow method crashes the compiler 2.12.x (only in REPL) #10358

Closed
@n4to4

Description

@n4to4

Scala version: 2.12.2 and 2.12.1

Shapeless' 42.narrow seems to crash the compiler only in REPL.
It seems fine when running in a program with sbt run.

build.sbt:

scalaVersion := "2.12.2"

libraryDependencies ++= Seq("com.chuusai" %% "shapeless" % "2.3.2")

How to reproduce:

$ sbt
sbt> console
[info] Starting scala interpreter...
[info]
Welcome to Scala 2.12.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_60).
Type in expressions for evaluation. Or try :help.

scala> import shapeless.syntax.singleton._
import shapeless.syntax.singleton._

scala> 42.narrow
scala.reflect.internal.Types$TypeError: assignment to non variable
        at scala.tools.nsc.typechecker.Contexts$ThrowingReporter.handleError(Contexts.scala:1402)
        at scala.tools.nsc.typechecker.Contexts$ContextReporter.issue(Contexts.scala:1254)
        at scala.tools.nsc.typechecker.Contexts$Context.issue(Contexts.scala:576)
        at scala.tools.nsc.typechecker.ContextErrors$ErrorUtils$.issueTypeError(ContextErrors.scala:106)
        at scala.tools.nsc.typechecker.ContextErrors$ErrorUtils$.issueNormalTypeError(ContextErrors.scala:99)
        at scala.tools.nsc.typechecker.ContextErrors$TyperContextErrors$TyperErrorGen$.AssignmentError(ContextErrors.scala:323)
        at scala.tools.nsc.typechecker.Typers$Typer.fail$2(Typers.scala:4338)
        at scala.tools.nsc.typechecker.Typers$Typer.typedAssign$1(Typers.scala:4341)
        at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5491)
        at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5520)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5527)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5563)
        at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5593)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5537)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5541)
        at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5624)
[...]
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        at sbt.Logger$$anon$4.apply(Logger.scala:84)
        at sbt.TrapExit$App.run(TrapExit.scala:248)
        at java.lang.Thread.run(Thread.java:745)

That entry seems to have slain the compiler.  Shall I replay
your session? I can re-run each line except the last one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions