Compile-time crash with invalid extractor return type.

38 views
Skip to first unread message

Christophe Calvès

unread,
Jul 31, 2015, 9:49:35 AM7/31/15
to scala-internals
Hi all,

 I encountered a compiler crash with the following code. Sorry if this is an already known issue (i checked on the issue tracker first, it seemed to be new).

object Extract {
 
def unapply[A](a : A) : String = a.toString
}
object Extractor extends App {
 
val a = 5 match { case Extract(x) => x  }
}


I am aware that String is not a valid return type for an extractor but it crashes in:

scala.reflect.internal.Types$TypeError: value get is not a member of String
        at scala
.tools.nsc.typechecker.Contexts$ThrowingReporter.handleError(Contexts.scala:1390)
        at scala
.tools.nsc.typechecker.Contexts$ContextReporter.issue(Contexts.scala:1242)
        at scala
.tools.nsc.typechecker.Contexts$Context.issue(Contexts.scala:573)
        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$.NotAMemberError(ContextErrors.scala:376)
        at scala
.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$lookupInQualifier$1(Typers.scala:4095)
        at scala
.tools.nsc.typechecker.Typers$Typer.handleMissing$1(Typers.scala:4744)

I tested it on a Linux (Ubuntu 15.04) amd64 machine running Scala version 2.11.7 and 2.11.6 with OpenJDK 64-Bit Server VM, Java 1.7.0_79. Both directly with scalac, in console and with sbt (0.13.8).

Best regards,
Christophe Calvès

Serge

unread,
Jul 31, 2015, 10:51:33 AM7/31/15
to scala-i...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Som Snytt

unread,
Jul 31, 2015, 1:50:56 PM7/31/15
to scala-internals
NAME-based is one of those recursive initialisms: NAME-based Anything Makes Exceptions.

We think of issues as having test cases, but really, releases should be characterized by the set of tests which are passing and the set of tests which are pending (known to be failing and accepted as pending issues).

That's my second thought after thinking, How could this be an issue?

Reply all
Reply to author
Forward
0 new messages