Skip to content

Stack overflow when rendering structural types with self references in quotes reflect #23142

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

Closed
jchyb opened this issue May 12, 2025 · 1 comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@jchyb
Copy link
Contributor

jchyb commented May 12, 2025

Compiler version

3.7.0 (and earlier and later)
Found when working on scaladoc

Minimized code

object Test:
  type R = { type T; val x: Int; type U <: this.T; }
  def main() = Macro.show[R]
import scala.quoted._
object Macro:
  inline def show[T] = ${ showImpl[T] }
  def showImpl[T: Type](using Quotes): Expr[Unit] =
    import quotes.reflect._
    println(TypeRepr.of[T].dealias.show(using Printer.TypeReprStructure))
    '{()}

Output

-- Error: /Users/jchyb/workspace/scala3/Test.scala:5:25 -------------------------
5 |  def main() = Macro.show[R]
  |               ^^^^^^^^^^^^^
  |               Exception occurred while executing macro expansion.
  |               java.lang.StackOverflowError
  |
  |-----------------------------------------------------------------------------
  |Inline stack trace
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |This location contains code that was inlined from Macro.scala:3
3 |  inline def show[T] = ${ showImpl[T] }
  |                       ^^^^^^^^^^^^^^^^
   -----------------------------------------------------------------------------

Expectation

No error

@jchyb jchyb added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 12, 2025
@TomasMikula
Copy link
Contributor

Looks like a duplicate of #22649, with a proposed fix in #22859.

@jchyb jchyb closed this as completed May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

2 participants