Skip to content
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

invalid prefix NoType when using report.errorAndAbort #19851

Closed
TomasMikula opened this issue Mar 1, 2024 · 2 comments · Fixed by #19883
Closed

invalid prefix NoType when using report.errorAndAbort #19851

TomasMikula opened this issue Mar 1, 2024 · 2 comments · Fixed by #19883

Comments

@TomasMikula
Copy link
Contributor

Compiler version

3.3.3
3.4.0
3.4.1-RC1

Minimized code

import scala.quoted.*

opaque type Box[A] = Any

object Box {
  transparent inline def pack[A]: Nothing => Box[A] =
    ${ packImpl[A] }

  private def packImpl[A](using
    Quotes,
    Type[A],
  ): Expr[Nothing => Box[A]] =
    import quotes.reflect.*
    report.errorAndAbort("Not implemented")
}
def main: Unit =
  Box.pack[Int]

Output (click arrow to expand)

[error] -- Error: /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/use.scala:2:10 ---
[error] 2 |  Box.pack[Int]
[error]   |  ^^^^^^^^^^^^^
[error]   |  Not implemented
[info] 
[info]   exception occurred while typechecking /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/use.scala
[info] 
[info]   An unhandled exception was thrown in the compiler.
[info]   Please file a crash report here:
[info]   https://github.com/lampepfl/dotty/issues/new/choose
[info]   For non-enriched exceptions, compile with -Yno-enrich-error-messages.
[info] 
[info]      while compiling: /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/use.scala
[info]         during phase: typer
[info]                 mode: Mode(ImplicitsEnabled)
[info]      library version: version 2.13.12
[info]     compiler version: version 3.4.0
[info]             settings: -bootclasspath /Users/tomas/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.0/scala3-library_3-3.4.0.jar:/Users/tomas/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -classpath /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/target/scala-3.4.0/classes -d /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/target/scala-3.4.0/classes

  Exception while compiling /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/defns.scala, /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/use.scala

  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: <no file>
        during phase: parser
                mode: Mode()
     library version: version 2.13.12
    compiler version: version 3.4.0
            settings: -bootclasspath /Users/tomas/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.0/scala3-library_3-3.4.0.jar:/Users/tomas/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -classpath /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/target/scala-3.4.0/classes -d /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/target/scala-3.4.0/classes

[error] ## Exception when compiling 2 sources to /Users/tomas/tmp/scalac-crash-invalid-prefix-NoType/target/scala-3.4.0/classes
[error] java.lang.AssertionError: assertion failed: invalid prefix NoType
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] dotty.tools.dotc.core.Types$NamedType.<init>(Types.scala:2296)
[error] dotty.tools.dotc.core.Types$TermRef.<init>(Types.scala:2901)
[error] dotty.tools.dotc.core.Types$CachedTermRef.<init>(Types.scala:2998)
[error] dotty.tools.dotc.core.Uniques$NamedTypeUniques.newType$1(Uniques.scala:44)
[error] dotty.tools.dotc.core.Uniques$NamedTypeUniques.linkedListLoop$1(Uniques.scala:56)
[error] dotty.tools.dotc.core.Uniques$NamedTypeUniques.enterIfNew(Uniques.scala:62)
[error] dotty.tools.dotc.core.Types$TermRef$.apply(Types.scala:3052)
[error] dotty.tools.dotc.core.Types$TermRef$.apply(Types.scala:3058)
[error] dotty.tools.dotc.ast.tpd$TreeOps$.select$extension(tpd.scala:930)
[error] dotty.tools.dotc.ast.tpd$TreeOps$.cast$extension(tpd.scala:1028)
[error] dotty.tools.dotc.ast.tpd$TreeOps$.cast$extension(tpd.scala:1023)
[error] dotty.tools.dotc.ast.tpd$TreeOps$.ensureConforms$extension(tpd.scala:1037)
[error] dotty.tools.dotc.inlines.Inlines$InlineCall.expand(Inlines.scala:491)
[error] dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:152)
[error] dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:4048)
[error] dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4156)
[error] dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4368)
[error] dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3679)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3391)
[error] dotty.tools.dotc.typer.Typer.$anonfun$62(Typer.scala:2602)
[error] dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
[error] dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2602)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3096)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3301)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3347)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2789)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3102)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3106)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3301)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3347)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2922)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3148)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3198)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3391)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:477)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
[error] dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
[error] scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
[error] scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
[error] scala.collection.immutable.List.prependedAll(List.scala:152)
[error] scala.collection.immutable.List$.from(List.scala:684)
[error] scala.collection.immutable.List$.from(List.scala:681)
[error] scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
[error] dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:100)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:337)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:348)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:357)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:71)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:357)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:267)
[error] dotty.tools.dotc.Driver.finish(Driver.scala:58)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:180)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:419)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:172)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2371)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2319)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error] java.base/java.lang.Thread.run(Thread.java:1583)
[error]            
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) java.lang.AssertionError: assertion failed: invalid prefix NoType
[error] Total time: 0 s, completed Mar 1, 2024, 9:19:50PM

Expected

The compiler should not crash and only report the explicit compilation error:

[error] 2 |  Box.pack[Int]
[error]   |  ^^^^^^^^^^^^^
[error]   |  Not implemented
@TomasMikula TomasMikula added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 1, 2024
@soronpo
Copy link
Contributor

soronpo commented Mar 1, 2024

Possible workaround:
Return the expression

'{compiletime.error("Not implemented")}

@TomasMikula
Copy link
Contributor Author

Possible workaround: Return the expression

'{compiletime.error("Not implemented")}

That would work for expressions, but sometimes I also want to errorAndAbort("Not implemented") from a method returning a Type[A].

@dwijnand dwijnand removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Mar 1, 2024
@dwijnand dwijnand self-assigned this Mar 1, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
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.

5 participants