-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
REPL: values that fail to initialise should not be accessible in later runs #4416
Comments
I want to try this. It looks like the problem is that a successful |
Good analysis! I suggest you patch It should probably return the old state if a failure occurs during evaluation. I think |
Ideally, I think we should decouple rendering and evaluation. But it's probably best implemented as another PR |
Just run today into a likely variant: scala> val x = ???; val y = x
scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:284)
at rs$line$1$.<init>(rs$line$1:1)
at rs$line$1$.<clinit>(rs$line$1)
at rs$line$1.x(rs$line$1)
...
java.lang.NoClassDefFoundError: Could not initialize class rs$line$1$
at rs$line$1.y(rs$line$1)
... Edited(@allanrenucci) for simplicity: REPL shouldn't try to initialise |
The right hand side of value definitions in the REPL are computed in the static initializer for the wrapper object created for that input line (e.g. rs$line$1). If any of these definitions throws an exception, the wrapper class will fail to initialize, and further attempts to use the class will throw NoClassDefFoundError. In this commit, we avoid all reflective access on a wrapper class once we notice that it failed to initialize, and mark that wrapper object as invalid in the REPL state. We discard all input from the failed wrapper (which may have been multi-line containing many statements and definitions); any types, terms, aliases, or imports defined there will not override any existing with the same name, and will not be accessible in subsequent runs. Fixes scala#4416 Fixes scala#14473
The text was updated successfully, but these errors were encountered: