scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.89k stars 1.06k forks source link

Compiler crash with tapir in scala 3.3.1 instead of cannot prove A =:= Unit #18602

Closed olivierdeckers closed 5 months ago

olivierdeckers commented 1 year ago

Compiler version

3.3.1

Minimized code

//> using scala 3.3.1
//> using dep com.softwaremill.sttp.tapir::tapir-zio-http-server:1.7.3

import sttp.tapir.*
import sttp.tapir.model.UsernamePassword

object Endpoints:
  val tokenEndpoint = endpoint.post
    .in("api" / "oauth2" / "token")
    .securityIn(auth.basic[UsernamePassword]())
    .in(formBody[String])
    // ommitted on purpose to trigger the bug 
    //    .serverSecurityLogicSuccess[Unit, Task](_ => ZIO.unit)
    .serverLogic(_ => ???)

Output (click arrow to expand)

```Error compiling project (Scala 3.3.1, JVM) Error: Unexpected error when compiling bug.scala: 'assertion failed' ```

Expected Output

[error] Cannot prove that sttp.tapir.model.UsernamePassword =:= Unit.
[error]     .serverLogic(_ => ???)
[error]                           ^
olivierdeckers commented 1 year ago

scala 3.3.0 is returning the expected output

soronpo commented 1 year ago

Missing full crash log. Missing minimization. Could be duplicate of #18589

KacperFKorban commented 1 year ago

You can add --server=false to the scala-cli to display the whole crash log. Here is the full log:

```scala java.lang.AssertionError: assertion failed while typechecking i18602.scala exception occurred while typechecking i18602.scala exception occurred while compiling List(i18602.scala) An unhandled exception was thrown in the compiler. Please file a crash report here: https://github.com/lampepfl/dotty/issues/new/choose while compiling: during phase: mode: Mode(ImplicitsEnabled) library version: version 2.13.10 compiler version: version 3.3.1 settings: -classpath ~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.1/scala3-library_3-3.3.1.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/tapir/tapir-zio-http-server_3/1.7.3/tapir-zio-http-server_3-1.7.3.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/tapir/tapir-server_3/1.7.3/tapir-server_3-1.7.3.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/tapir/tapir-zio_3/1.7.3/tapir-zio_3-1.7.3.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-http_3/3.0.0-RC2/zio-http_3-3.0.0-RC2.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/tapir/tapir-core_3/1.7.3/tapir-core_3-1.7.3.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio_3/2.0.16/zio_3-2.0.16.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-streams_3/2.0.16/zio-streams_3-2.0.16.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/shared/zio_3/1.3.16/zio_3-1.3.16.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.93.Final/netty-codec-http-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-handler-proxy/4.1.93.Final/netty-handler-proxy-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.93.Final/netty-transport-native-epoll-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.93.Final/netty-transport-native-epoll-4.1.93.Final-linux-x86_64.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.93.Final/netty-transport-native-epoll-4.1.93.Final-linux-aarch_64.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-kqueue/4.1.93.Final/netty-transport-native-kqueue-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-kqueue/4.1.93.Final/netty-transport-native-kqueue-4.1.93.Final-osx-x86_64.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-kqueue/4.1.93.Final/netty-transport-native-kqueue-4.1.93.Final-osx-aarch_64.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-schema_3/0.4.11/zio-schema_3-0.4.11.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-schema-json_3/0.4.11/zio-schema-json_3-0.4.11.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/incubator/netty-incubator-transport-native-io_uring/0.0.20.Final/netty-incubator-transport-native-io_uring-0.0.20.Final-linux-x86_64.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/model/core_3/1.7.2/core_3-1.7.2.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/shared/core_3/1.3.16/core_3-1.3.16.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/sttp/shared/ws_3/1.3.16/ws_3-1.3.16.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/softwaremill/magnolia1_3/magnolia_3/1.3.3/magnolia_3-1.3.3.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-internal-macros_3/2.0.16/zio-internal-macros_3-2.0.16.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-stacktracer_3/2.0.16/zio-stacktracer_3-2.0.16.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/izumi-reflect_3/2.3.8/izumi-reflect_3-2.3.8.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-common/4.1.93.Final/netty-common-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-buffer/4.1.93.Final/netty-buffer-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport/4.1.93.Final/netty-transport-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-codec/4.1.93.Final/netty-codec-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-handler/4.1.93.Final/netty-handler-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-codec-socks/4.1.93.Final/netty-codec-socks-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.93.Final/netty-transport-native-unix-common-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-classes-epoll/4.1.93.Final/netty-transport-classes-epoll-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-classes-kqueue/4.1.93.Final/netty-transport-classes-kqueue-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-schema-macros_3/0.4.11/zio-schema-macros_3-0.4.11.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-prelude_3/1.0.0-RC18/zio-prelude_3-1.0.0-RC18.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-constraintless_3/0.3.2/zio-constraintless_3-0.3.2.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-schema-derivation_3/0.4.11/zio-schema-derivation_3-0.4.11.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-json_3/0.5.0/zio-json_3-0.5.0.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/incubator/netty-incubator-transport-classes-io_uring/0.0.20.Final/netty-incubator-transport-classes-io_uring-0.0.20.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/izumi-reflect-thirdparty-boopickle-shaded_3/2.3.8/izumi-reflect-thirdparty-boopickle-shaded_3-2.3.8.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-resolver/4.1.93.Final/netty-resolver-4.1.93.Final.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/dev/zio/zio-prelude-macros_3/1.0.0-RC18/zio-prelude-macros_3-1.0.0-RC18.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-collection-compat_3/2.9.0/scala-collection-compat_3-2.9.0.jar -d .scala-build/bugs_cc5ffaca6e-28a16d953d/classes/main -java-output-version 11 -sourceroot ~/bugs tree: EmptyTree tree position: : tree type: symbol: val call site: package in module class == Source file context for tree position == Exception in thread "main" java.lang.AssertionError: assertion failed at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11) at dotty.tools.dotc.ast.tpd$.TypeApply(tpd.scala:60) at dotty.tools.dotc.ast.tpd$TreeOps$.appliedToTypeTrees$extension(tpd.scala:985) at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4255) at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587) at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:497) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:897) at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:589) at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:653) at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:492) at dotty.tools.dotc.typer.Applications$TypedApply.(Applications.scala:779) at dotty.tools.dotc.typer.Applications$ApplyToUntyped.(Applications.scala:896) at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1126) at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:352) at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:116) at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:969) at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1052) at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3324) at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1063) at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1101) at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:352) at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:116) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3048) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) at dotty.tools.dotc.typer.Implicits.tryConversion$1(Implicits.scala:1136) at dotty.tools.dotc.typer.Implicits.typedImplicit(Implicits.scala:1167) at dotty.tools.dotc.typer.Implicits.typedImplicit$(Implicits.scala:818) at dotty.tools.dotc.typer.Typer.typedImplicit(Typer.scala:116) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.tryImplicit(Implicits.scala:1242) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.rank$1(Implicits.scala:1341) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1511) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1539) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:1547) at dotty.tools.dotc.typer.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1572) at dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:1060) at dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:818) at dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:116) at dotty.tools.dotc.typer.Implicits.inferView(Implicits.scala:856) at dotty.tools.dotc.typer.Implicits.inferView$(Implicits.scala:818) at dotty.tools.dotc.typer.Typer.inferView(Typer.scala:116) at dotty.tools.dotc.typer.Implicits.viewExists(Implicits.scala:831) at dotty.tools.dotc.typer.Implicits.viewExists$(Implicits.scala:818) at dotty.tools.dotc.typer.Typer.viewExists(Typer.scala:116) at dotty.tools.dotc.typer.Implicits.ignoredConvertibleImplicits$1$$anonfun$3(Implicits.scala:960) at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479) at scala.collection.Iterator.isEmpty(Iterator.scala:466) at scala.collection.Iterator.isEmpty$(Iterator.scala:466) at scala.collection.AbstractIterator.isEmpty(Iterator.scala:1300) at scala.collection.View$Filter.isEmpty(View.scala:146) at scala.collection.IterableOnceOps.nonEmpty(IterableOnce.scala:833) at scala.collection.IterableOnceOps.nonEmpty$(IterableOnce.scala:833) at scala.collection.AbstractIterable.nonEmpty(Iterable.scala:933) at dotty.tools.dotc.reporting.MissingImplicitArgument.noChainConversionsNote$1(messages.scala:2838) at dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript$$anonfun$4(messages.scala:2846) at scala.Option.orElse(Option.scala:477) at dotty.tools.dotc.reporting.MissingImplicitArgument.msgPostscript(messages.scala:2846) at dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:345) at dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:341) at dotty.tools.dotc.reporting.Message.message(Message.scala:345) at dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:322) at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:16) at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden$(HideNonSensicalMessages.scala:10) at dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8) at dotty.tools.dotc.reporting.Reporter.issueUnconfigured(Reporter.scala:156) at dotty.tools.dotc.reporting.Reporter.go$1(Reporter.scala:181) at dotty.tools.dotc.reporting.Reporter.issueIfNotSuppressed(Reporter.scala:200) at dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:203) at dotty.tools.dotc.report$.error(report.scala:68) at dotty.tools.dotc.typer.Typer.issueErrors$1$$anonfun$1(Typer.scala:3808) at scala.runtime.function.JProcedure3.apply(JProcedure3.java:15) at scala.runtime.function.JProcedure3.apply(JProcedure3.java:10) at scala.collection.LazyZip3.foreach(LazyZipOps.scala:248) at dotty.tools.dotc.typer.Typer.issueErrors$1(Typer.scala:3810) at dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:3832) at dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:3849) at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4038) at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4268) at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3587) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1653) at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1643) at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1653) at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1906) at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:243) at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1906) at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1914) at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1932) at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1933) at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1944) at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1691) at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1698) at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:787) at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:934) at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:814) at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174) at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187) at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189) at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393) at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2989) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3014) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3210) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256) at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2669) at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3036) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3040) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3111) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3210) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3256) at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2812) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3081) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3300) at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44) at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54) at scala.Function0.apply$mcV$sp(Function0.scala:42) at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:440) at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54) at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.immutable.List.foreach(List.scala:333) at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88) at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246) 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:1321) at dotty.tools.dotc.Run.runPhases$1(Run.scala:262) at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270) at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279) at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67) at dotty.tools.dotc.Run.compileUnits(Run.scala:279) at dotty.tools.dotc.Run.compileSources(Run.scala:194) at dotty.tools.dotc.Run.compile(Run.scala:179) at dotty.tools.dotc.Driver.doCompile(Driver.scala:37) at dotty.tools.dotc.Driver.process(Driver.scala:197) at dotty.tools.dotc.Driver.process(Driver.scala:165) at dotty.tools.dotc.Driver.process(Driver.scala:177) at dotty.tools.dotc.Driver.main(Driver.scala:207) at dotty.tools.dotc.Main.main(Main.scala) ```

Also, a dependency-free minimization will be needed.

WojciechMazur commented 5 months ago

The issue was fixed since 3.3.2, and works also correctly in all 3.4.x and 3.5.x versions