-
Notifications
You must be signed in to change notification settings - Fork 138
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
Allow to use object as a script wrapper #2117
Comments
This has probably a link with the classOf Operation, If I use the REPL I get :
So using the REPL we can see that we got May be a classloader issue ? wrong parent classloader ? Something scalatest is doing that is no longer compatible with the new behavior of scala-cli ? |
It seems that the reason for this issue is the new script wrapper for Scala 3 scripts introduced in #2033.
//> using scala "3.2.2"
//> using dep "org.scalatest::scalatest:3.2.16"
import org.scalatest.*, flatspec.*, matchers.*
class Outer {
class PiTest extends AnyFlatSpec with should.Matchers {
"pi calculus" should "return a precise enough pi value" in {
math.Pi shouldBe 3.14158d +- 0.001d
}
}
}
object Main extends App {
org.scalatest.tools.Runner.main(Array("-oDF", "-s", classOf[Outer#PiTest].getName))
} The problem seems to be the loading of the inner class. scala-cli --cli-version 1.0.0-RC1 Main.scala
# *** RUN ABORTED *** Needs further investigation on how can we address this. BTW. the example in the REPL (given in #2117 (comment)) is actually replicable in earlier versions of Scala CLI and may be a separate issue. |
Ok, so it seems there is no way around it unless we go back to the old behaviour (but that has issues with deadlocks, so I think it's more problematic) or we provide an additional using directive to use object. Neither approach is great but I would stay with the current approach. In the meantime, I would however suggest using a normal Scala file in this case, sorry about the inconvenience. We can leave this open to see if more people need this fixed (please react with +1). |
fwiw, I agree that these deadlocks are so common and so pernicious that it's worth prioritizing avoiding them, even if it means compromising a bit elsewhere. the deadlock-proneness of the Scala 2 REPL, before we similarly switched to class-based wrappers in Scala 2.13.2, was reported on scala/bug and elsewhere about a million times over the years, and it was often language newcomers reporting it and getting a bad impression of Scala (for evidence, see scala/bug#8119 and the various similar/duplicate tickets that are a link or two away) cc @som-snytt |
You can now use |
Version(s)
Only from 1.0.0-RC2, everything is fine with previous releases.
Describe the bug
.
The script compile, then a
*** RUN ABORTED***
message is printed(Of course I could use the new
test.dep
andscl test myscript.sc
approach but it should run as before the old way)To Reproduce
Expected behaviour
![image](https://private-user-images.githubusercontent.com/381901/238130616-e1b5fd12-6f50-4c14-9d95-90ce7f4ce781.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4OTc3ODEsIm5iZiI6MTczOTg5NzQ4MSwicGF0aCI6Ii8zODE5MDEvMjM4MTMwNjE2LWUxYjVmZDEyLTZmNTAtNGMxNC05ZDk1LTkwY2U3ZjRjZTc4MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOFQxNjUxMjFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yN2NjYWVlNzdlYTdhMGI4NTU5NzdhMDcyZjE2YzYzZDM5YjAyYzU5MDFkMTUyMjUyMmIxM2Y4OTcyYThkYzMzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.IXJz6bcJ0lsCN4ob-n93vcwP3uGIY-hknpdxTey_nYw)
running fine without this error message and with this output :
The text was updated successfully, but these errors were encountered: