-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Reject failed inits #4434
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
Reject failed inits #4434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
Also found another weird behavior: Without this patch:
With the patch:
Which seems better, maybe not ideal. |
).foreach(str => out.println(SyntaxHighlighting(str))) | ||
|
||
state.copy(valIndex = state.valIndex - vals.filter(resAndUnit).length) | ||
val (successes, failures) = vals.map(rendering.renderVal).partition(_.isSuccess) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should stop rendering vals after the first failure, like scalac REPL:
scala> val x = 1 / 0; println("1")
java.lang.ArithmeticException: / by zero
... 28 elided
In the example above, println("1")
is not evaluated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And not render anything (e.g. aliases, methods) in case of failure
val resultValue = | ||
if (d.symbol.is(Flags.Lazy)) Some("<lazy>") | ||
else valueOf(d.symbol) | ||
|
||
resultValue.map(value => s"$dcl = $value") | ||
} | ||
catch { case ex: InvocationTargetException => Some(renderError(ex)) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should propagate any exception that is not an InvocationTargetException
@allanrenucci I managed to get this working. For some reason to do with classloaders I don't fully understand, the
My PR now creates a new |
@allanrenucci Since this was not re-assigned to you it probably fell through the cracks. Can you take a look and decide whether this can go in now? Thanks |
@ankitson Sorry for the long silence. Do still plan to work on this PR? The latest commits seems like a hack rather than a clean solution; a |
Closing for now, feel free to reopen if you plan to further work on it! |
This is a fix for #4416 . Its still WIP, some cleanup & style fixes needed I think, but the basic idea is here so I thought I would open it up to suggestions.
@allanrenucci It mostly does what you suggested, except we also have to patch
compile
to account for failures indisplayDefinitions
.It doesn't seem very clean, but it is explicit about the dependency between
display
and the REPL state. I think it will remain a little messy until we decouple eval and rendering.