-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #3305 and #3309 #3314
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
Fix #3305 and #3309 #3314
Conversation
/** Render the stack trace of the underlying exception */ | ||
private def renderError(ex: InvocationTargetException): String = { | ||
val cause = ex.getCause match { | ||
case ex: ExceptionInInitializerError => ex.getCause |
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.
I am trying to isolate the underlying exception. This is based on nothing but experiment:
> null.toString
Exception in thread "main" java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.ExceptionInInitializerError
...
Caused by: java.lang.NullPointerException
...
scala> def foo: Int = foo + 1
def foo: Int
scala> foo
Exception in thread "main" java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.StackOverflowError
...
I am sure there is a better a way to do it.
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 really need tests for all of those :)
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.
Working on it
In case of an exception, the result still get assigned to a value. Maybe this can be fixed in another PR. scala> null.toString
java.lang.NullPointerException
at rs$line$1$.<init>(rs$line$1:1)
at rs$line$1$.<clinit>(rs$line$1)
...
scala> res0
java.lang.NoClassDefFoundError: Could not initialize class rs$line$1$
at rs$line$2$.<init>(rs$line$2:1)
at rs$line$2$.<clinit>(rs$line$2)
at rs$line$2.res1Show(rs$line$2) |
Also, the commit message titles could be improved to say what is being fixed, not just give the issue number. |
ff301fb
to
aebf6f4
Compare
1d0e727
to
095a6b7
Compare
@@ -235,10 +235,14 @@ class ReplCompiler(val directory: AbstractFile) extends Compiler { | |||
EmptyValDef, | |||
state.imports.map(_._1) :+ valdef) | |||
|
|||
val pos = | |||
if (trees.isEmpty) Position(0, expr.length) | |||
else Position(trees.head.pos.start, trees.last.pos.end) |
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.
@felixmulder Should the position always be Position(0, expr.length)
?
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.
You're creating the wrapper here - so it needs to have a position that spans all the trees, looks equivalent :)
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.
Then I would rather not special case
When auto-completing in the REPL, we sometime tried to manipulate a tree with no position. Not anymore
The new REPL did not catch exceptions. We now handle exceptions but there is a lot of room for improvement when reporting an exception.
095a6b7
to
f25fa1f
Compare
scala> } | ||
1 | } | ||
| ^ | ||
| eof expected, but '}' found |
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.
@felixmulder Why do I need a space after |
, even though when I run the repl on my machine it doesn't print the space. Is it a bug in the testing framework?
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.
Sounds like it!
f65ee87
to
3144646
Compare
No description provided.