Skip to content

complier is crashed in LambdaLift when macro rewrite lambda which rewrite yet-one lambda-expression inside which enclose symbols. #9894

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 Sep 27, 2020 · 2 comments

Comments

@rssh
Copy link
Contributor

rssh commented Sep 27, 2020

Minimized code

package x

import scala.quoted._

trait CB[T]:
 def map[S](f: T=>S): CB[S] = ???

class MyArr[A]:
 def map1[B](f: A=>B):MyArr[B] = ???
 def map1Out[B](f: A=> CB[B]): CB[MyArr[B]] = ???

def await[T](x:CB[T]):T = ???

object CBM:
  def pure[T](t:T):CB[T] = ???

object X:

 inline def process[T](inline f:T) = ${
   processImpl[T]('f)
 }
 def processImpl[T:Type](f:Expr[T])(using qctx: QuoteContext):Expr[CB[T]] =
   import qctx.tasty._

   def transform(term:Term):Term =
     term match
        case Apply(TypeApply(Select(obj,"map1"),targs),args) =>
             val nArgs = args.map(x => shiftLambda(x))
             val nSelect = Select.unique(obj, "map1Out")
             Apply(TypeApply(nSelect,targs),nArgs)
        case Apply(TypeApply(Ident("await"),targs),args) => args.head
        case Apply(x,y) =>
             Apply(x, y.map(transform))
        case Block(stats, last) => Block(stats, transform(last))
        case Inlined(x,List(),body) => transform(body)
        case l@Literal(x) =>
             '{ CBM.pure(${term.seal}) }.unseal
        case other =>
             throw RuntimeException(s"Not supported $other")

   def shiftLambda(term:Term): Term =
        term match
          case lt@Lambda(params, body) =>
            val paramTypes = params.map(_.tpt.tpe)
            val paramNames = params.map(_.name)
            val mt = MethodType(paramNames)(_ => paramTypes, _ => '[CB].unseal.tpe.appliedTo(body.tpe.widen) )
            Lambda(mt, args => changeArgs(params,args,transform(body)) )
          case Block(stats, last) =>
            Block(stats, shiftLambda(last))
          case _ =>
            throw RuntimeException("lambda expected")

   def changeArgs(oldArgs:List[Tree], newArgs:List[Tree], body:Term):Term =
         val association: Map[Symbol, Term] = (oldArgs zip newArgs).foldLeft(Map.empty){
             case (m, (oldParam, newParam: Term)) => m.updated(oldParam.symbol, newParam)
             case (m, (oldParam, newParam: Tree)) => throw RuntimeException("Term expected")
         }
         val changes = new TreeMap() {
             override def transformTerm(tree:Term)(using Context): Term =
               tree match
                 case ident@Ident(name) => association.getOrElse(ident.symbol, super.transformTerm(tree))
                 case _ => super.transformTerm(tree)
         }
         changes.transformTerm(body)

   transform(f.unseal).seal.cast[CB[T]]

and in Main.scala:

package x


object Main {

 def main(args:Array[String]):Unit =
   val arr = new MyArr[Int]()
   val r = X.process{
       arr.map1( zDebug =>
         await(CBM.pure(1).map(a => zDebug + a))
       )
   }
   println("r")

}

Output (click arrow to expand)

```scala atest Dotty nightly build version: 0.28.0-bin-20200925-f4528ce-NIGHTLY [info] loading settings for project root from build.sbt ... [info] set current project to test (in build file:/Users/rssh/tests/dotty/crash-compiler/) [info] Executing in batch mode. For better performance use sbt's shell [info] Compiling 2 Scala sources to /Users/rssh/tests/dotty/crash-compiler/target/scala-0.28/classes ...

java.util.NoSuchElementException: key not found: method $anonfun while traversing zDebug:Int/T
java.util.NoSuchElementException: key not found: method $anonfun while traversing <zDebug:Int/T.+:(x: Int/T): Int/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing <<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing <
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing <
<
<<x.CBM:x.CBM[ModuleClass]/T.pure:((t: Object/T): x.CB/T)>(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):Integer/T>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<<x.CBM:x.CBM[ModuleClass]/T.pure:((t: Object/T): x.CB/T)>(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):Integer/T>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing <
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<<x.CBM:x.CBM[ModuleClass]/T.pure:((t: Object/T): x.CB/T)>(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):Integer/T>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(zDebug:Object/T):Int/T>
):x.CB/T>
<closure(<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>):
Function1/T
>
}
:Function1/T>
}
:Function1/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing <<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<<x.CBM:x.CBM[ModuleClass]/T.pure:((t: Object/T): x.CB/T)>(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):Integer/T>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(zDebug:Object/T):Int/T
>
):x.CB/T>
<closure(<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>):
Function1/T
>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing <
<<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
< Compile / compileIncremental 3s
<<x.CBM:x.CBM[ModuleClass]/T.pure:((t: Object/T): x.CB/T)>(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):Integer/T>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(zDebug:Object/T):
Int/T
>
):x.CB/T>
<closure(<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>):
Function1/T
>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
:x.CB/T:x.CB/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing val r: x.CB/T =
<
<<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<<x.CBM:x.CBM[ModuleClass]/T.pure:((t: Object/T): x.CB/T)>(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):Integer/T>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(zDebug:Object/T):
Int/T
>
):x.CB/T>
<closure(<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>):
Function1/T
>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
:x.CB/T:x.CB/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing <
{
val arr: x.MyArr/T =
<<<new x.MyArr/T:x.MyArr/T>:((): x.MyArr/T)>():x.MyArr/T>
val r: x.CB/T =
<
<<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<<x.CBM:x.CBM[ModuleClass]/T.pure:((t: Object/T): x.CB/T)>
(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):
Integer/T
>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):Int/T
>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(
zDebug:Object/T
):Int/T>
):x.CB/T>
<closure(
<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>
):Function1/T>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
:x.CB/T:x.CB/T>
<<println:((x: Object/T): Unit/T)>(<"r":String/T>):Unit/T>
}
:Unit/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing def main(args: String/T[]): Unit/T =
<
{
val arr: x.MyArr/T =
<<<new x.MyArr/T:x.MyArr/T>:((): x.MyArr/T)>():x.MyArr/T>
val r: x.CB/T =
<
<<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<
<x.CBM:x.CBM[ModuleClass]/T.pure:
((t: Object/T): x.CB/T)
>
(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):
Integer/T
>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):
Int/T
>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(
zDebug:Object/T
):Int/T>
):x.CB/T>
<closure(
<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>
):Function1/T>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
:x.CB/T:x.CB/T>
<<println:((x: Object/T): Unit/T)>(<"r":String/T>):Unit/T>
}
:Unit/T>
java.util.NoSuchElementException: key not found: method $anonfun while traversing extends Object/T {
def (): Unit/T =
<
{
<<<super:(x.Main : Object/T)>:((): Object/T)>():Object/T>
<():Unit/T>
}
:Unit/T>
private def writeReplace(): Object/T =
<
<
<new scala.runtime.ModuleSerializationProxy/T:
scala.runtime.ModuleSerializationProxy/T
>
:((x$0: Class/T): scala.runtime.ModuleSerializationProxy/T)>
(<classOf[x.Main[ModuleClass]/T]:Class/T>):
scala.runtime.ModuleSerializationProxy/T
>
def main(args: String/T[]): Unit/T =
<
{
val arr: x.MyArr/T =
<<<new x.MyArr/T:x.MyArr/T>:((): x.MyArr/T)>():x.MyArr/T>
val r: x.CB/T =
<
<<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<
<x.CBM:x.CBM[ModuleClass]/T.pure:
((t: Object/T): x.CB/T)
>
(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):
Integer/T
>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):
Int/T
>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(
zDebug:Object/T
):Int/T>
):x.CB/T>
<closure(
<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>
):Function1/T>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
:x.CB/T:x.CB/T>
<<println:((x: Object/T): Unit/T)>(<"r":String/T>):Unit/T>
}
:Unit/T>
}
java.util.NoSuchElementException: key not found: method $anonfun while traversing @<
<
<new scala.annotation.internal.SourceFile/T:
scala.annotation.internal.SourceFile/T
>
:((path: String/T): scala.annotation.internal.SourceFile/T)>
(
<"/Users/rssh/tests/dotty/crash-compiler/src/main/scala/x/Main.scala":
("/Users/rssh/tests/dotty/crash-compiler/src/main/scala/x/Main.scala" :
String/T
)

):scala.annotation.internal.SourceFile/T> final module class Main[ModuleClass]/T
extends
Object/T {
def (): Unit/T =
<
{
<<<super:(x.Main : Object/T)>:((): Object/T)>():Object/T>
<():Unit/T>
}
:Unit/T>
private def writeReplace(): Object/T =
<
<
<new scala.runtime.ModuleSerializationProxy/T:
scala.runtime.ModuleSerializationProxy/T
>
:((x$0: Class/T): scala.runtime.ModuleSerializationProxy/T)>
(<classOf[x.Main[ModuleClass]/T]:Class/T>):
scala.runtime.ModuleSerializationProxy/T
>
def main(args: String/T[]): Unit/T =
<
{
val arr: x.MyArr/T =
<<<new x.MyArr/T:x.MyArr/T>:((): x.MyArr/T)>():x.MyArr/T>
val r: x.CB/T =
<
<<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<
<x.CBM:x.CBM[ModuleClass]/T.pure:
((t: Object/T): x.CB/T)
>
(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):
Integer/T
>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>):
Int/T
>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T =
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(
zDebug:Object/T
):Int/T>
):x.CB/T>
<closure(
<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>
):Function1/T>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
:x.CB/T:x.CB/T>
<<println:((x: Object/T): Unit/T)>(<"r":String/T>):Unit/T>
}
:Unit/T>
}
java.util.NoSuchElementException: key not found: method $anonfun while traversing <package <x:x/T> {
final lazy module val Main: x.Main[ModuleClass]/T =
<
<<new x.Main[ModuleClass]/T:x.Main[ModuleClass]/T>:
((): x.Main[ModuleClass]/T)
>
():x.Main[ModuleClass]/T>
@<
<
<new scala.annotation.internal.SourceFile/T:
scala.annotation.internal.SourceFile/T
>
:((path: String/T): scala.annotation.internal.SourceFile/T)>
(
<"/Users/rssh/tests/dotty/crash-compiler/src/main/scala/x/Main.scala":
("/Users/rssh/tests/dotty/crash-compiler/src/main/scala/x/Main.scala" :
String/T
)
>
):scala.annotation.internal.SourceFile/T> final module class
Main[ModuleClass]/T
extends Object/T {
def (): Unit/T =
<
{
<<<super:(x.Main : Object/T)>:((): Object/T)>():Object/T>
<():Unit/T>
}
:Unit/T>
private def writeReplace(): Object/T =
<
<
<new scala.runtime.ModuleSerializationProxy/T:
scala.runtime.ModuleSerializationProxy/T
>
:((x$0: Class/T): scala.runtime.ModuleSerializationProxy/T)>
(<classOf[x.Main[ModuleClass]/T]:Class/T>):
scala.runtime.ModuleSerializationProxy/T
>
def main(args: String/T[]): Unit/T =
<
{
val arr: x.MyArr/T =
<<<new x.MyArr/T:x.MyArr/T>:((): x.MyArr/T)>():x.MyArr/T>
val r: x.CB/T =
<
<<arr:x.MyArr/T.map1Out:((f: Function1/T): x.CB/T)>(
<
{
def $anonfun(zDebug: Int/T): x.CB/T =
<
<
<
<x.CBM:x.CBM[ModuleClass]/T.pure:
((t: Object/T): x.CB/T)
>
(
<<scala.Int.box:((x: Int/T): Integer/T)>(<1:Int/T>):
Integer/T
>
):x.CB/T>
.map:((f: Function1/T): x.CB/T)>
(
<
{
def $anonfun(a: Int/T): Int/T =
<<zDebug:Int/T.+:((x: Int/T): Int/T)>(<a:Int/T>)
:
Int/T>
<closure(<$anonfun:(a: Int/T): Int/T>:
dotty.runtime.function.JFunction1$mcII$sp/T
):dotty.runtime.function.JFunction1$mcII$sp/T>
}
:dotty.runtime.function.JFunction1$mcII$sp/T>
):x.CB/T>
<
{
def $anonfun[Suffix $adapted](zDebug: Object/T): x.CB/T
=
<<$anonfun:((zDebug: Int/T): x.CB/T)>(
<<scala.Int.unbox:((x: Object/T): Int/T)>(
zDebug:Object/T
):Int/T>
):x.CB/T>
<closure(
<$anonfun[Suffix $adapted]:(zDebug: Object/T): x.CB/T>
):Function1/T>
}
:Function1/T>
}
:Function1/T>
):x.CB/T>
:x.CB/T:x.CB/T>
<<println:((x: Object/T): Unit/T)>(<"r":String/T>):Unit/T>
}
:Unit/T>
}
}:x.type>
java.util.NoSuchElementException: key not found: method $anonfun while compiling /Users/rssh/tests/dotty/crash-compiler/src/main/scala/x/Main.scala, /Users/rssh/tests/dotty/crash-compiler/src/main/scala/x/X.scala
[error] ## Exception when compiling 2 sources to /Users/rssh/tests/dotty/crash-compiler/target/scala-0.28/classes
[error] java.util.NoSuchElementException: key not found: method $anonfun
[error] scala.collection.MapOps.default(Map.scala:251)
[error] scala.collection.MapOps.default$(Map.scala:250)
[error] scala.collection.AbstractMap.default(Map.scala:381)
[error] scala.collection.MapOps.apply(Map.scala:153)
[error] scala.collection.MapOps.apply$(Map.scala:152)
[error] scala.collection.AbstractMap.apply(Map.scala:381)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter.narrowLiftedOwner(LambdaLift.scala:99)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter.dotty$tools$dotc$transform$LambdaLift$Lifter$$markFree(LambdaLift.scala:162)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter.dotty$tools$dotc$transform$LambdaLift$Lifter$$markFree(LambdaLift.scala:161)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:212)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1400)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1406)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1475)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1385)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1387)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1420)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1385)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1387)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1406)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1475)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1385)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1387)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1420)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1385)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1387)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1406)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1414)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1471)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1385)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1387)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1420)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1475)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1385)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1387)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1482)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1479)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1510)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1385)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1387)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1486)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1511)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter$CollectDependencies.traverse(LambdaLift.scala:250)
[error] dotty.tools.dotc.transform.LambdaLift$Lifter.(LambdaLift.scala:374)
[error] dotty.tools.dotc.transform.LambdaLift.prepareForUnit(LambdaLift.scala:531)
[error] dotty.tools.dotc.transform.MegaPhase.prepUnit(MegaPhase.scala:1040)
[error] dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:447)
[error] dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:460)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:296)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
[error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
[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:195)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
[error] dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:63)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:210)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:152)
[error] dotty.tools.dotc.Driver.finish$1(Driver.scala:48)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:51)
[error] dotty.tools.dotc.Driver.process(Driver.scala:195)
[error] dotty.tools.dotc.Main.process(Main.scala)
[error] xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
[error] xsbt.CompilerInterface.run(CompilerInterface.java:41)
[error] java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] java.base/java.lang.reflect.Method.invoke(Method.java:564)
[error] sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
....

</details>

 Debug shows, that the 'enclosing chain of zDebug symbol'  inside map contains lambda-expression which was rewritten (and therefore can't be found). 
@rssh
Copy link
Contributor Author

rssh commented Sep 27, 2020

crash-compiler.tar.gz

full archive with sbt project

@rssh
Copy link
Contributor Author

rssh commented Sep 27, 2020

Looks like enclosing.enclosing in symbol Ident(zDebug) inside inner map point to rewritten lambda. (which can't be found).

rssh added a commit to rssh/dotty that referenced this issue Oct 31, 2020
liufengyun added a commit that referenced this issue Nov 2, 2020
Fix #9894: Fix owner when constructing a Lambda
rssh added a commit to dotty-cps-async/dotty-cps-async that referenced this issue Nov 3, 2020
 (some compiler issues are left, need further research)
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.

2 participants