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

Class wrapper causes infinite evaluation/evaluation to fail #853

Open
kasiaMarek opened this issue Mar 26, 2024 · 0 comments
Open

Class wrapper causes infinite evaluation/evaluation to fail #853

kasiaMarek opened this issue Mar 26, 2024 · 0 comments

Comments

@kasiaMarek
Copy link

For the following code evaluation gets stuck in a loop for Scala 2 and throws StackOverflowException for Scala 3.

class Animal(age: Int)

class Rabbit(age: Int) extends Animal(age):
  val id = Rabbit.tag
  Rabbit.tag += 1
  def getId = id

object Rabbit:
  val basic = Rabbit(0)
  var tag: Int = 0

val peter = Rabbit(2)

Upstream issue: scalameta/metals#4796

The problem is caused by class MdocApp wrapper. Changing it to object MdocApp fixes the issue but causes other issues (with thread deadlocks), full track of this problem in kept in scala-cli repository: VirtusLab/scala-cli#2247.

A proper fix should divide the code so classes/objects etc. are put in an object and rest is put inside of a class. Preferably the solution should be done in such a way it can be shared between mdoc and scala-cli (e.g. the compiler repl).

@kasiaMarek kasiaMarek changed the title Valid scala code in worksheets causes infinite evaluation/evaluation to fail with an error due to worksheet class wrapper Class wrapper causes infinite evaluation/evaluation to fail Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant