Skip to content

Crash while unpickling type quote #5247

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

Closed
nicolasstucki opened this issue Oct 12, 2018 · 1 comment
Closed

Crash while unpickling type quote #5247

nicolasstucki opened this issue Oct 12, 2018 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

import scala.quoted._
object Test {
  def main(args: Array[String]): Unit = {
    implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
    foo[Object].show
  }
  def foo[H : Type]: Expr[H] = {
    val t = '[H]
    '{ null.asInstanceOf[~t] }
  }
}

the compiler crashes while unpickling '[H] with

Caused by: scala.MatchError: 140 (of class java.lang.Integer)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthType$1(TreeUnpickler.scala:357)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readType(TreeUnpickler.scala:401)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1177)
	at dotty.tools.dotc.core.tasty.TreeUnpickler.unpickle(TreeUnpickler.scala:99)
	at dotty.tools.dotc.core.tasty.DottyUnpickler.computeRootTrees(DottyUnpickler.scala:61)
	at dotty.tools.dotc.ast.tpd$TreeProvider.rootTrees(tpd.scala:973)
	at dotty.tools.dotc.ast.tpd$TreeProvider.tree(tpd.scala:977)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.unpickle(PickledQuotes.scala:113)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.unpickleType(PickledQuotes.scala:76)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.quotedTypeToTree(PickledQuotes.scala:62)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readHole(TreeUnpickler.scala:1219)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthType$1(TreeUnpickler.scala:357)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readType(TreeUnpickler.scala:401)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1177)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$13(TreeUnpickler.scala:1056)
	at dotty.tools.dotc.core.tasty.TastyReader.until(TastyReader.scala:125)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1056)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1163)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1067)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1163)
	at dotty.tools.dotc.core.tasty.TreeUnpickler.unpickle(TreeUnpickler.scala:98)
	at dotty.tools.dotc.core.tasty.DottyUnpickler.computeRootTrees(DottyUnpickler.scala:61)
	at dotty.tools.dotc.ast.tpd$TreeProvider.rootTrees(tpd.scala:973)
	at dotty.tools.dotc.ast.tpd$TreeProvider.tree(tpd.scala:977)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.unpickle(PickledQuotes.scala:113)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.unpickleExpr(PickledQuotes.scala:70)
	at dotty.tools.dotc.core.quoted.PickledQuotes$.quotedExprToTree(PickledQuotes.scala:44)
	at dotty.tools.dotc.quoted.QuoteCompiler$QuotedFrontend.runOn$$anonfun$1(QuoteCompiler.scala:53)
	...
@nicolasstucki
Copy link
Contributor Author

Changing the code to

  def foo[H](implicit t0: Type[H]): Expr[H] = {
    val t = '[~t0]
    '{ null.asInstanceOf[~t] }
  }

fixes the issue. There is probably with tryHeal in ReifyQuotes

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 16, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 16, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 16, 2018
Type block are represented with `Block` nodes where all statements
are `TypeDef`s and the expression is a `TypeTree`.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 16, 2018
Type block are represented with `Block` nodes where all statements
are `TypeDef`s and the expression is a `TypeTree`.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 16, 2018
Type block are represented with `Block` nodes where all statements
are `TypeDef`s and the expression is a `TypeTree`.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 16, 2018
Type block are represented with `Block` nodes where all statements
are `TypeDef`s and the expression is a `TypeTree`.
nicolasstucki added a commit that referenced this issue Oct 20, 2018
Fix #5247: Support type blocks and fix generic tuples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant