scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Crash in compilation from tasty

Open WojciechMazur opened this issue 1 year ago • 4 comments

Compilation from tasty of this code has always failed, however, recently it stated to crash compiler instead of returning error. This issue points to 2 bugs:

  1. It should return compilation error instead of crash
  2. It should successfully compile from TASTy

Compiler version

Last good release: 3.4.0-RC1-bin-20231030-e2c9dc0-NIGHTLY First bad release: 3.4.0-RC1-bin-20231031-58810fd-NIGHTLY Bisect points to 7fc4341dffdb32fb573b13c53c2611789a1ba640

Minimized code

trait CP[A,B]
trait TypeEqK[F[_], G[_]]

trait Knit[CP[_, _], F[_]] {
  type Res

  def visit[R](
    caseInFst: [F1[_], Y] => (k: Knit[CP, F1]) => (ev: TypeEqK[F, [x] =>> CP[F1[x], Y]]) => R
  ): R
}

Output (click arrow to expand)

 exception occurred while readTasty class file Knit

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.

     while compiling: class file Knit
        during phase: readTasty
                mode: Mode(ImplicitsEnabled,ReadPositions)
     library version: version 2.13.12
    compiler version: version 3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY-git-5c628d9
            settings: -Yread-docs true -Yretain-trees true -classpath /Users/wmazur/projects/sandbox/.scala-build/sandbox_3200b05eac-c94a8248fb/classes/main/:/Users/wmazur/projects/sandbox/.scala-build/sandbox_3200b05eac-c94a8248fb/classes/main:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY/scala3-library_3-3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scaladoc_3/3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY/scaladoc_3-3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY/scala3-compiler_3-3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-tasty-inspector_3/3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY/scala3-tasty-inspector_3-3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark/0.62.2/flexmark-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-ast/0.62.2/flexmark-util-ast-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-data/0.62.2/flexmark-util-data-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-html/0.62.2/flexmark-util-html-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-anchorlink/0.62.2/flexmark-ext-anchorlink-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-autolink/0.62.2/flexmark-ext-autolink-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-emoji/0.62.2/flexmark-ext-emoji-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-gfm-strikethrough/0.62.2/flexmark-ext-gfm-strikethrough-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-gfm-tasklist/0.62.2/flexmark-ext-gfm-tasklist-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-wikilink/0.62.2/flexmark-ext-wikilink-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-tables/0.62.2/flexmark-ext-tables-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-yaml-front-matter/0.62.2/flexmark-ext-yaml-front-matter-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/nl/big-o/liqp/0.8.2/liqp-0.8.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jsoup/jsoup/1.17.2/jsoup-1.17.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.15.1/jackson-dataformat-yaml-2.15.1.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-interfaces/3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY/scala3-interfaces-3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY/scala3-library_3-3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/tasty-core_3/3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY/tasty-core_3-3.4.1-RC1-bin-20240205-5c628d9-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-asm/9.6.0-scala-1/scala-asm-9.6.0-scala-1.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/compiler-interface/1.9.6/compiler-interface-1.9.6.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-reader/3.19.0/jline-reader-3.19.0.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal/3.19.0/jline-terminal-3.19.0.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal-jna/3.19.0/jline-terminal-jna-3.19.0.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-builder/0.62.2/flexmark-util-builder-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-collection/0.62.2/flexmark-util-collection-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-dependency/0.62.2/flexmark-util-dependency-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-format/0.62.2/flexmark-util-format-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-misc/0.62.2/flexmark-util-misc-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-sequence/0.62.2/flexmark-util-sequence-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-visitor/0.62.2/flexmark-util-visitor-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/15.0/annotations-15.0.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util/0.62.2/flexmark-util-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/nibor/autolink/autolink/0.6.0/autolink-0.6.0.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-jira-converter/0.62.2/flexmark-jira-converter-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.15.1/jackson-annotations-2.15.1.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.15.1/jackson-core-2.15.1.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.15.1/jackson-databind-2.15.1.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.1/jackson-datatype-jsr310-2.12.1.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/ua/co/k/strftime4j/1.0.5/strftime4j-1.0.5.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/yaml/snakeyaml/2.0/snakeyaml-2.0.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/util-interface/1.9.8/util-interface-1.9.8.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/net/java/dev/jna/jna/5.3.1/jna-5.3.1.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-options/0.62.2/flexmark-util-options-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-ins/0.62.2/flexmark-ext-ins-0.62.2.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-superscript/0.62.2/flexmark-ext-superscript-0.62.2.jar -from-tasty true

Exception in thread "main" java.lang.AssertionError: assertion failed: owner discrepancy for type x, expected: parameter ev, found: method apply
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.symbolAtCurrent(TreeUnpickler.scala:300)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.indexParams(TreeUnpickler.scala:826)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readParams(TreeUnpickler.scala:1217)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTree$1(TreeUnpickler.scala:1519)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTree(TreeUnpickler.scala:1556)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1581)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$40(TreeUnpickler.scala:1512)
        at dotty.tools.tasty.TastyReader.until(TastyReader.scala:135)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTree$1(TreeUnpickler.scala:1512)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTree(TreeUnpickler.scala:1556)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1581)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1567)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:960)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:851)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedParams$$anonfun$2(TreeUnpickler.scala:1213)
        at dotty.tools.tasty.TastyReader.collectWhile(TastyReader.scala:147)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedParams(TreeUnpickler.scala:1213)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readParams(TreeUnpickler.scala:1218)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readParamss$1(TreeUnpickler.scala:869)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:905)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:851)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:1145)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:1197)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readStats(TreeUnpickler.scala:1207)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTree$1(TreeUnpickler.scala:1505)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTree(TreeUnpickler.scala:1556)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1581)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:906)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:851)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:1145)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:1197)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readStats(TreeUnpickler.scala:1207)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTree$1(TreeUnpickler.scala:1505)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTree(TreeUnpickler.scala:1556)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTpt(TreeUnpickler.scala:1581)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:960)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:851)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedParams$$anonfun$2(TreeUnpickler.scala:1213)
        at dotty.tools.tasty.TastyReader.collectWhile(TastyReader.scala:147)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedParams(TreeUnpickler.scala:1213)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readParams(TreeUnpickler.scala:1218)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readParamss$1(TreeUnpickler.scala:869)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readRest$1(TreeUnpickler.scala:867)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readParamss$1(TreeUnpickler.scala:870)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:905)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:851)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:1145)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:1197)
        at dotty.tools.dotc.core.tasty.TreeUnpickler.$anonfun$23$$anonfun$1(TreeUnpickler.scala:1112)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$LazyReader.complete(TreeUnpickler.scala:1696)
        at dotty.tools.dotc.ast.Trees$WithLazyFields.force(Trees.scala:1124)
        at dotty.tools.dotc.ast.Trees$WithLazyFields.force$(Trees.scala:1120)
        at dotty.tools.dotc.ast.Trees$Template.force(Trees.scala:968)
        at dotty.tools.dotc.ast.Trees$Template.forceFields(Trees.scala:974)
        at dotty.tools.dotc.ast.Trees$Template.parentsOrDerived(Trees.scala:978)
        at dotty.tools.dotc.ast.Trees$Template.parents(Trees.scala:980)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1755)
        at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1797)
        at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:195)
        at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1796)
        at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1796)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1752)
        at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1797)
        at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:195)
        at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1796)
        at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1796)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1660)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1662)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1761)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1666)
        at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1797)
        at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:195)
        at dotty.tools.dotc.CompilationUnit$.apply(CompilationUnit.scala:143)
        at dotty.tools.dotc.CompilationUnit$.apply(CompilationUnit.scala:134)
        at dotty.tools.dotc.fromtasty.ReadTasty.compilationUnit$1(ReadTasty.scala:57)
        at dotty.tools.dotc.fromtasty.ReadTasty.readTASTY(ReadTasty.scala:85)
        at dotty.tools.dotc.fromtasty.ReadTasty.addTasty$$anonfun$1(ReadTasty.scala:33)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:477)
        at dotty.tools.dotc.fromtasty.ReadTasty.addTasty(ReadTasty.scala:33)
        at dotty.tools.dotc.fromtasty.ReadTasty.runOn$$anonfun$1(ReadTasty.scala:28)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576)
        at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:933)
        at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:903)
        at dotty.tools.dotc.fromtasty.ReadTasty.runOn(ReadTasty.scala:28)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:337)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:350)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:360)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:360)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:267)
        at dotty.tools.dotc.fromtasty.TASTYRun.compile(TASTYRun.scala:15)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:196)
        at dotty.tools.dotc.Driver.process(Driver.scala:164)
        at dotty.tools.dotc.Driver.process(Driver.scala:176)
        at scala.tasty.inspector.TastyInspector$.inspectFiles(TastyInspector.scala:121)
        at scala.tasty.inspector.TastyInspector$.inspectAllTastyFiles(TastyInspector.scala:62)
        at dotty.tools.scaladoc.tasty.ScaladocTastyInspector$.loadDocs(TastyParser.scala:163)
        at dotty.tools.scaladoc.ScalaModuleProvider$.mkModule(ScalaModuleProvider.scala:11)
        at dotty.tools.scaladoc.Scaladoc$.run(Scaladoc.scala:240)
        at dotty.tools.scaladoc.Scaladoc$.run$$anonfun$1(Scaladoc.scala:70)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.Option.map(Option.scala:242)
        at dotty.tools.scaladoc.Scaladoc$.run(Scaladoc.scala:74)
        at dotty.tools.scaladoc.Main.run(Main.scala:8)
        at dotty.tools.scaladoc.Main$.main(Main.scala:14)
        at dotty.tools.scaladoc.Main.main(Main.scala)

WojciechMazur avatar Feb 06 '24 13:02 WojciechMazur

I don't think the bisect is correct. Both of those nightly versions crash with the -from-tasty option for me

also pretty much any commit is failing to compile this code with testCompilation tests/pos/i19629.scala even from way back to https://github.com/lampepfl/dotty/commit/44a537b340695dfa847fbda1ed12c60053c80deb and even https://github.com/lampepfl/dotty/commit/a4e669aeb5bad74ac6e46642875a5f296b2acbdb which are before any of the progress tracking stuff - i.e. im getting the same crash

bishabosha avatar Feb 22 '24 17:02 bishabosha

@WojciechMazur this even crashes in the exact same way since 3.0.0, maybe you have some different steps to reproduce the "ok" version?

bishabosha avatar Feb 22 '24 17:02 bishabosha

I assume that if it compiles fine with standard compilation, and fails only if --from-tasty option is present then there must be something wrong in this compilation mode. There's more issues related to compilation --from-tasty and I expected that everything that compiles from sources should also compile from tasty.

WojciechMazur avatar Feb 22 '24 18:02 WojciechMazur

I'm fine to treat it as just a standard tasty error, but I'm wondering how you got it to not crash and instead make a normal error

bishabosha avatar Feb 22 '24 23:02 bishabosha

with some improved debugging output, we get this error:

assertion failed: owner discrepancy for local type x @ 237, expected: local parameter ev @ 276, found: local method apply @ 153

this becomes clear why with the TASTy generated:

  129:       DEFDEF(161) 19 [visit]
   133:         TYPEPARAM(7) 20 [R]
   136:           TYPEBOUNDStpt(4)
   138:             SHAREDtype 17
   140:             SHAREDtype 23
   142:         PARAM(143) 21 [caseInFst]
   146:           REFINEDtpt(139)
   149:             TYPEREF 22 [PolyFunction]
   151:               SHAREDtype 19
   153:             DEFDEF(132) 23 [apply]
   157:               TYPEPARAM(18) 24 [F1]
   160:                 LAMBDAtpt(15)
   162:                   TYPEPARAM(7) 25 [[Unique _$ 6]]
   165:                     TYPEBOUNDStpt(4)
   167:                       SHAREDtype 17
   169:                       SHAREDtype 23
   171:                   TYPEBOUNDStpt(4)
   173:                     SHAREDtype 17
   175:                     SHAREDtype 23
   177:               TYPEPARAM(7) 26 [Y]
   180:                 TYPEBOUNDStpt(4)
   182:                   SHAREDtype 17
   184:                   SHAREDtype 23
   186:               PARAM(23) 27 [k]
   189:                 APPLIEDtpt(20)
   191:                   IDENTtpt 2 [Knit]
   193:                     TYPEREFsymbol 5
   195:                       THIS
   196:                         TYPEREFpkg 1 [<empty>]
   198:                   IDENTtpt 3 [CP]
   200:                     TYPEREFsymbol 12
   202:                       THIS
   203:                         SHAREDtype 193
   206:                   IDENTtpt 24 [F1]
   208:                     TYPEREFdirect 157
   211:               REFINEDtpt(74)
   213:                 APPLIEDtpt(58)
   215:                   TYPEREF 28 [Function1]
   217:                     SHAREDtype 19
   219:                   APPLIEDtpt(49)
   221:                     IDENTtpt 29 [TypeEqK]
   223:                       TYPEREF 29 [TypeEqK]
   225:                         SHAREDtype 195
   228:                     IDENTtpt 10 [F]
   230:                       TYPEREFsymbol 41
   232:                         SHAREDtype 202
   235:                     LAMBDAtpt(33)
   237:                       TYPEPARAM(7) 30 [x]
   240:                         TYPEBOUNDStpt(4)
   242:                           SHAREDtype 17
   244:                           SHAREDtype 23
   246:                       APPLIEDtpt(22)
   248:                         IDENTtpt 3 [CP]
   250:                           SHAREDtype 200
   253:                         APPLIEDtpt(10)
   255:                           IDENTtpt 24 [F1]
   257:                             SHAREDtype 208
   260:                           IDENTtpt 30 [x]
   262:                             TYPEREFdirect 237
   265:                         IDENTtpt 26 [Y]
   267:                           TYPEREFdirect 177
   270:                   TYPEREFdirect 133
   273:                 DEFDEF(12) 23 [apply]
   276:                   PARAM(4) 31 [ev]
   279:                     SHAREDterm 219
   282:                   IDENTtpt 20 [R]
   284:                     SHAREDtype 270
   287:               SYNTHETIC
   288:         IDENTtpt 20 [R]
   290:           SHAREDtype 270

because the final result type (ev: TypeEqK[F, [x] =>> CP[F1[x], Y]]) => R is a dependent function type, we end up duplicating the type arguments to Function1 in a refinement F1[G[[x] => x], R] { def apply(ev: G[[x] => x]): R }. This is optimised in TASTy as a SHAREDterm. Normally this is ok, but in this example, we cause a crash because we need to create two symbols that share the same address, and the TreeUnpickler isn't equipped for this.

Here is the trace:

at address 276 we re-index the parameters of apply, starting with ev, then we read the SHAREDterm 219, which causes us to re-index the type lambda [x] =>> CP[F1[x], Y], starting with type parameter x @ 237. The problem is that we already created a symbol at that address when we were indexing the result type of apply @ 153, so currentSymbol complains.

bishabosha avatar Feb 29 '24 16:02 bishabosha

According to @sjrd this has to be fixed before it reaches TASTy, e.g. by having a type derived from the tree, rather than duplicating the tree - otherwise there's a whole mess in trying to keep track of which symbols have duplicates

bishabosha avatar Mar 01 '24 08:03 bishabosha