Skip to content

Recursion limit exceeded with structural types in the REPL #23133

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
TomasMikula opened this issue May 9, 2025 · 2 comments
Open

Recursion limit exceeded with structural types in the REPL #23133

TomasMikula opened this issue May 9, 2025 · 2 comments
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@TomasMikula
Copy link
Contributor

Compiler version

3.7.0

Minimized code

Insert the following 2 snippets in the REPL, one at a time:

Snippet 1

val obj: scala.reflect.Selectable {
  val schemas: { type Pet }
  val pets: List[schemas.Pet]
} = 
  new scala.reflect.Selectable {
    val schemas: { type Pet } = new Object { type Pet = Unit }
    val pets: List[schemas.Pet] = Nil
  }

Snippet 2

obj.pets

Output

% scala
Welcome to Scala 3.7.0 (21, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                                                                                                                             
scala> val obj: scala.reflect.Selectable {
     |   val schemas: { type Pet }
     |   val pets: List[schemas.Pet]
     | } = 
     |   new scala.reflect.Selectable {
     |     val schemas: { type Pet } = new Object { type Pet = Unit }
     |     val pets: List[schemas.Pet] = Nil
     |   }
     | 
val obj:
  {z1 =>
    scala.reflect.Selectable{
      val schemas: Object{type Pet}; val pets: List[z1.schemas.Pet]}
  } = anon$1@66456506
                                                                                                                                                                                                                                                                                             
scala> obj.pets
-- Error: ----------------------------------------------------------------------
1 |obj.pets
  |    ^
  |Recursion limit exceeded.
  |Maybe there is an illegal cyclic reference?
  |If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
  |For the unprocessed stack trace, compile with -Xno-enrich-error-messages.
  |A recurring operation is (inner to outer):
  |
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  ...
  |
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member Selectable#schemas
  |  find-member obj.pets
1 error found

Expectation

It should work, just like when compiled with scalac.

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

3 participants
@TomasMikula and others