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

Compiler crash in 3.7 nightly while compiling http4s-related code, "invalid new prefix" #22737

Closed
mrdziuban opened this issue Mar 7, 2025 · 6 comments
Assignees
Labels
area:extension-methods itype:bug regression This worked in a previous version but doesn't anymore stat:duplicate stat:needs minimization Needs a self contained minimization

Comments

@mrdziuban
Copy link

Compiler version

3.7.0-RC1-bin-20250306-73ba485-NIGHTLY

Minimized code

//> using dep org.http4s::http4s-core:0.23.30

import cats.effect.IO
import org.http4s.EntityBody

type Response = org.http4s.Response[IO]

extension (res: Response) {
  def withEntity(f: EntityBody[IO] => EntityBody[IO]): Response = res.copy(body = f(res.body))
}

Output

  unhandled exception while running MegaPhase{crossVersionChecks, firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks, dropForMap} on /Users/matt/scala3.7-http4s-crash/src/main/scala/example/Test.scala

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


     while compiling: /Users/matt/scala3.7-http4s-crash/src/main/scala/example/Test.scala
        during phase: MegaPhase{crossVersionChecks, firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks, dropForMap}
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.16
    compiler version: version 3.7.0-RC1-bin-20250306-73ba485-NIGHTLY-git-73ba485
            settings: -classpath /Users/matt/scala3.7-http4s-crash/target/scala-3.7.0-RC1-bin-20250306-73ba485-NIGHTLY/classes:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.7.0-RC1-bin-20250306-73ba485-NIGHTLY/scala3-library_3-3.7.0-RC1-bin-20250306-73ba485-NIGHTLY.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/http4s/http4s-core_3/0.23.30/http4s-core_3-0.23.30.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.16/scala-library-2.13.16.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/case-insensitive_3/1.4.2/case-insensitive_3-1.4.2.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/cats-core_3/2.11.0/cats-core_3-2.11.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/cats-effect-std_3/3.5.7/cats-effect-std_3-3.5.7.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/cats-parse_3/1.0.0/cats-parse_3-1.0.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/http4s/http4s-crypto_3/0.2.4/http4s-crypto_3-0.2.4.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/co/fs2/fs2-core_3/3.11.0/fs2-core_3-3.11.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/co/fs2/fs2-io_3/3.11.0/fs2-io_3-3.11.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/comcast/ip4s-core_3/3.6.0/ip4s-core_3-3.6.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/literally_3/1.1.0/literally_3-1.1.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scodec/scodec-bits_3/1.1.38/scodec-bits_3-1.1.38.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/vault_3/3.6.0/vault_3-3.6.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/log4s/log4s_3/1.10.0/log4s_3-1.10.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/log4cats-slf4j_3/2.7.0/log4cats-slf4j_3-2.7.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/cats-kernel_3/2.11.0/cats-kernel_3-2.11.0.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/cats-effect-kernel_3/3.5.7/cats-effect-kernel_3-3.5.7.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/cats-effect_3/3.5.4/cats-effect_3-3.5.4.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/Users/matt/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/typelevel/log4cats-core_3/2.7.0/log4cats-core_3-2.7.0.jar -d /Users/matt/scala3.7-http4s-crash/target/scala-3.7.0-RC1-bin-20250306-73ba485-NIGHTLY/classes

## Exception when compiling 1 sources to /Users/matt/scala3.7-http4s-crash/target/scala-3.7.0-RC1-bin-20250306-73ba485-NIGHTLY/classes
dotty.tools.dotc.core.TypeError$$anon$1: invalid new prefix  = org.http4s.Response[cats.effect.IO] cannot replace (Message.this : org.http4s.Message[F] & org.http4s.Message[F]) in type Message.this.Self

Expectation

It should compile without any error, as in previous versions

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 7, 2025
@mrdziuban
Copy link
Author

Interestingly, without the type Response alias there's no error, i.e. this compiles fine

import cats.effect.IO
import org.http4s.{EntityBody, Response}

extension (res: Response[IO]) {
  def withEntity(f: EntityBody[IO] => EntityBody[IO]): Response[IO] = res.copy(body = f(res.body))
}

@mrdziuban
Copy link
Author

Possibly related to #22727 since that also uses a type alias and an extension method, cc @hamzaremmal

@Gedochao
Copy link
Contributor

Gedochao commented Mar 7, 2025

Last good release: 3.7.0-RC1-bin-20250222-4dc4668-NIGHTLY
First bad release: 3.7.0-RC1-bin-20250225-a25fe5e-NIGHTLY
The first bad commit is 7d79c56
cc @hamzaremmal

Possibly related to #22727 since that also uses a type alias and an extension method, cc @hamzaremmal

Suspecting it might be a duplicate, we'd need to minimize it without the dependency to be sure.
Leaving it open until we confirm.

@Gedochao Gedochao added area:extension-methods regression This worked in a previous version but doesn't anymore stat:duplicate and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 7, 2025
@Gedochao Gedochao added the stat:needs minimization Needs a self contained minimization label Mar 7, 2025
@som-snytt
Copy link
Contributor

I'm checking the extension check right now, as I have an open PR that touches that code. I'll update in a moment.

@som-snytt
Copy link
Contributor

I confirm it fails with 3.nightly 3.7.0-RC1-bin-20250306-73ba485-NIGHTLY-git-73ba485

but not with local #22708

I'll tweak to convince myself that the PR is the fix.

@som-snytt
Copy link
Contributor

som-snytt commented Mar 7, 2025

OK, I confirmed that it crashes without the tweak in the PR.

This is not a duplicate ticket (for that PR), so I'll reference this ticket. I see you mean it duplicates another report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:extension-methods itype:bug regression This worked in a previous version but doesn't anymore stat:duplicate stat:needs minimization Needs a self contained minimization
Projects
None yet
Development

No branches or pull requests

4 participants