Skip to content

Crash from mapping on NonEmptyTuple.toList #12721

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

Open
soronpo opened this issue Jun 5, 2021 · 0 comments
Open

Crash from mapping on NonEmptyTuple.toList #12721

soronpo opened this issue Jun 5, 2021 · 0 comments

Comments

@soronpo
Copy link
Contributor

soronpo commented Jun 5, 2021

Compiler version

v3.0.1-RC1

Minimized code

  def bar(t: Any): Int = 1
  def foo(t: AnyRef): Unit =
    t.asInstanceOf[NonEmptyTuple].toList.map(bar)

Output (click arrow to expand)

java.lang.AssertionError: assertion failed: [33m[0m [35m<none>[0m
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:721)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2665)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2757)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2943)
	at dotty.tools.dotc.transform.Erasure$Typer.typedTypeApply(Erasure.scala:815)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2714)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2758)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2943)
	at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:837)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2695)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2758)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2876)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2899)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1053)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1023)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1027)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2703)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2758)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2943)
	at dotty.tools.dotc.typer.Typer.$anonfun$34(Typer.scala:2168)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2168)
	at dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:955)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2672)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2757)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2849)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2899)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1053)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2354)
	at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1043)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2683)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2687)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2757)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2849)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2899)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1053)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2477)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2728)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2758)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2943)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:132)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:303)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
	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$5(Run.scala:216)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:224)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:231)
	at dotty.tools.dotc.Run.compileSources(Run.scala:166)
	at dotty.tools.dotc.Run.compile(Run.scala:150)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
	at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
	at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:186)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:176)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:157)
	at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
	at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:157)
	at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
	at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:174)
	at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:172)
	at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:457)
	at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
	at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
	at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
	at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261)
	at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:412)
	at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499)
	at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:399)
	at sbt.internal.inc.Incremental$.apply(Incremental.scala:166)
	at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
	at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
	at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
	at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
	at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2346)
	at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2303)
	at sbt.internal.io.Retry$.apply(Retry.scala:46)
	at sbt.internal.io.Retry$.apply(Retry.scala:28)
	at sbt.internal.io.Retry$.apply(Retry.scala:23)
	at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
	at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2299)
	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
	at sbt.Execute.work(Execute.scala:291)
	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

exception while typing {
  val Tuple_this: NonEmptyTuple = t.asInstanceOf[NonEmptyTuple]
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
    ]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.map of class class dotty.tools.dotc.ast.Trees$Select # -1
exception while typing {
  val Tuple_this: NonEmptyTuple = t.asInstanceOf[NonEmptyTuple]
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
    ]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.map[Int] of class class dotty.tools.dotc.ast.Trees$TypeApply # -1
exception while typing {
  val Tuple_this: NonEmptyTuple = t.asInstanceOf[NonEmptyTuple]
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
    ]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.map[Int](
  {
    def $anonfun(t: Any): Int = bar(t)
    closure($anonfun)
  }
) of class class dotty.tools.dotc.ast.Trees$Apply # -1
exception while typing {
  {
    val Tuple_this: NonEmptyTuple = t.asInstanceOf[NonEmptyTuple]
    (
      Tuple_this.productIterator.toList.asInstanceOf[
        scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
      ]
    :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
  }.map[Int](
    {
      def $anonfun(t: Any): Int = bar(t)
      closure($anonfun)
    }
  )
  ()
} of class class dotty.tools.dotc.ast.Trees$Block # -1
exception while typing def foo(t: AnyRef): Unit = 
  {
    {
      val Tuple_this: NonEmptyTuple = t.asInstanceOf[NonEmptyTuple]
      (
        Tuple_this.productIterator.toList.asInstanceOf[
          scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
        ]
      :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
    }.map[Int](
      {
        def $anonfun(t: Any): Int = bar(t)
        closure($anonfun)
      }
    )
    ()
  } of class class dotty.tools.dotc.ast.Trees$DefDef # -1
exception while typing @scala.annotation.internal.SourceFile("src/main/scala/main.scala") final module 
  class
 main$package$() extends Object() {
  private def writeReplace(): AnyRef = 
    new scala.runtime.ModuleSerializationProxy(classOf[main$package.type])
  def bar(t: Any): Int = 1
  def foo(t: AnyRef): Unit = 
    {
      {
        val Tuple_this: NonEmptyTuple = t.asInstanceOf[NonEmptyTuple]
        (
          Tuple_this.productIterator.toList.asInstanceOf[
            scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
          ]
        :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
      }.map[Int](
        {
          def $anonfun(t: Any): Int = bar(t)
          closure($anonfun)
        }
      )
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
  final lazy module val main$package: main$package$ = new main$package$()
  @scala.annotation.internal.SourceFile("src/main/scala/main.scala") final 
    module
   class main$package$() extends Object() {
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(classOf[main$package.type])
    def bar(t: Any): Int = 1
    def foo(t: AnyRef): Unit = 
      {
        {
          val Tuple_this: NonEmptyTuple = t.asInstanceOf[NonEmptyTuple]
          (
            Tuple_this.productIterator.toList.asInstanceOf[
              
                scala.collection.immutable.List[
                  Tuple.Union[(Tuple_this : Product)]
                ]
              
            ]
          :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
        }.map[Int](
          {
            def $anonfun(t: Any): Int = bar(t)
            closure($anonfun)
          }
        )
        ()
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
java.lang.AssertionError: assertion failed:  <none> while compiling /tmp/scastie5499222352497606134/src/main/scala/main.scala
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 9, 2021
This method failed for any subtype of `Tuple`.
It only worked for `Tuple` and `TupleN` as these define their own `toList`.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 9, 2021
This method failed for any subtype of `Tuple`.
It only worked for `Tuple` and `TupleN` as these define their own `toList`.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 10, 2021
This method failed for any subtype of `Tuple`.
It only worked for `Tuple` and `TupleN` as these define their own `toList`.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 28, 2021
This method failed for any subtype of `Tuple`.
It only worked for `Tuple` and `TupleN` as these define their own `toList`.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 28, 2021
This should in theory be backwards TASTy compatible.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 28, 2021
This should in theory be backwards TASTy compatible.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 28, 2021
This method failed for any subtype of `Tuple`.
It only worked for `Tuple` and `TupleN` as these define their own `toList`.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 28, 2021
This should in theory be backwards TASTy compatible.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 29, 2021
This method failed for any subtype of `Tuple`.
It only worked for `Tuple` and `TupleN` as these define their own `toList`.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 29, 2021
This should in theory be backwards TASTy compatible.

Fixes scala#12721
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 4, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Old definitions are made tasty compatible and just delegate to the new
representation.

Fixes scala#12721
Fixes scala#15992
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 7, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Old definitions are made tasty compatible and just delegate to the new
representation.

Fixes scala#12721
Fixes scala#15992
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 7, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Old definitions are made tasty compatible and just delegate to the new
representation.

Fixes scala#12721
Fixes scala#15992
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 8, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 4, 2024
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
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