Skip to content

Compiler crash during pickling when extracting type info from quotation #7892

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
rssh opened this issue Jan 4, 2020 · 1 comment · Fixed by #8796
Closed

Compiler crash during pickling when extracting type info from quotation #7892

rssh opened this issue Jan 4, 2020 · 1 comment · Fixed by #8796

Comments

@rssh
Copy link
Contributor

rssh commented Jan 4, 2020

minimized code

package a

import scala.quoted._
import scala.quoted.matching._


package x {

case class CExprResult1[F[_],T](
                origin:Expr[T],
                originType: Type[T]
)

}


import x._

trait M1[F[_]] {}

case class TC[F[_],T](
   patternCode: Expr[T],  // code, for which we build pattern expression
   patternType: Type[T],
   m1: Expr[M1[F]],
)

object Async1 {

 def rootTransform[F[_]:Type,T:Type](f: Expr[T], dm:Expr[M1[F]])(
                                           given qctx: QuoteContext): CExprResult1[F,T] = ???

}


class AssignTransform1[F[_]:Type,T:Type](cpsCtx: TC[F,T])

  import cpsCtx._

  // case Assign(left,right)
  def run(given qctx: QuoteContext)(left: qctx.tasty.Term, right: qctx.tasty.Term): CExprResult1[F,T] = {
     import qctx.tasty.{_, given}
     val cpsLeft = left.seal match {
        case '{ $le: $lt } =>
            Async1.rootTransform(le,m1)
     }
     val cpsRight = right.seal match {
        case '{ $re: $rt } =>
            Async1.rootTransform(re,m1)
     }
     run1(left,right,cpsLeft,cpsRight)
     ???
  }


  def run1[L:Type,R:Type](given qctx: QuoteContext)(left: qctx.tasty.Term, right: qctx.tasty.Term,
                cpsLeft: CExprResult1[F,L], cpsRight: CExprResult1[F,R]): CExprResult1[F,T] =
     import qctx.tasty.{_, given}
     ???

Stack trace
error] assertion failed: unresolved symbols: value cpsLeft(line 42) when pickling /Users/rssh/tests/scala-misc/dotty/assigntp/assigntp/src/main/scala/a/AssignTransform1.scala
[error] dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:704)
[error] dotty.tools.dotc.core.quoted.PickledQuotes$.pickle(PickledQuotes.scala:103)
[error] dotty.tools.dotc.core.quoted.PickledQuotes$.pickleQuote(PickledQuotes.scala:35)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.pickleAsTasty$1(ReifyQuotes.scala:236)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.pickledQuote(ReifyQuotes.scala:244)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transformQuotation(ReifyQuotes.scala:196)
[error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:93)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:415)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1347)
[error] scala.collection.immutable.List.mapConserve(List.scala:444)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1347)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1257)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:117)
[error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:76)
[error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:126)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:415)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1347)
[error] scala.collection.immutable.List.mapConserve(List.scala:444)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1347)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1345)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1271)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:89)
[error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:76)
[error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:105)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:415)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:97)
[error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:76)
[error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:126)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:415)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:51)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:58)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:108)
[error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:76)
[error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:126)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:415)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1327)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:101)
[error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:76)
[error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:126)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:415)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$2(Trees.scala:1347)
[error] scala.collection.immutable.List.mapConserve(List.scala:444)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1347)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1345)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1333)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:101)
[error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:76)
[error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:126)
[error] dotty.tools.dotc.transform.ReifyQuotes$QuoteReifier.transform(ReifyQuotes.scala:415)
[error] dotty.tools.dotc.transform.ReifyQuotes$$anon$1.transform(ReifyQuotes.scala:93)
[error] dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
[error] dotty.tools.dotc.transform.ReifyQuotes.run(ReifyQuotes.scala:89)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
[error] scala.collection.immutable.List.map(List.scala:219)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
[error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$5(Run.scala:171)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179)
[error] dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:186)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:123)
[error] dotty.tools.dotc.Run.compile(Run.scala:106)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
[error] dotty.tools.dotc.Driver.process(Driver.scala:189)
[error] dotty.tools.dotc.Main.process(Main.scala)
[error] xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
@nicolasstucki
Copy link
Contributor

Minimized to

import scala.quoted._

package x {
  class CExprResult1[T]
}

def run(given qctx: QuoteContext): Unit = {
  val cpsLeft: x.CExprResult1[?] = ???
  run1(cpsLeft)
}

def run1[L:Type](cpsLeft: x.CExprResult1[L]): Unit = ???

@biboudis biboudis assigned biboudis and unassigned nicolasstucki Jan 20, 2020
@biboudis biboudis changed the title crashes when extracting type info from quotation Compiler crash during pickling when extracting type info from quotation Jan 20, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2020
Fix scala#6140, fix scala#6772, fix scala#7030, fix scala#7892, fix scala#7997, fix scala#8651 and improve scala#8100.

Differences with previous implementation
* Only track and check levels within quotes or splices
* Track levels of all symbols not at level 0
* Split level checking into specialized variants for types and terms (healType/healTermType)
* Detect inconsistent types rather than try to detect consistent ones
* Check/heal term inconsistencies only on leaf nodes (TypeTree, RefTree, Ident, This)
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 4, 2020
Fix scala#6140, fix scala#6772, fix scala#7030, fix scala#7892, fix scala#7997, fix scala#8651 and improve scala#8100.

Differences with previous implementation
* Only track and check levels within quotes or splices
* Track levels of all symbols not at level 0
* Split level checking into specialized variants for types and terms (healType/healTermType)
* Detect inconsistent types rather than try to detect consistent ones
* Check/heal term inconsistencies only on leaf nodes (TypeTree, RefTree, Ident, This)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants