Skip to content

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

Merged
merged 3 commits into from
Oct 13, 2017
Merged

Fix #3305 and #3309 #3314

merged 3 commits into from
Oct 13, 2017

Conversation

allanrenucci
Copy link
Contributor

No description provided.

/** Render the stack trace of the underlying exception */
private def renderError(ex: InvocationTargetException): String = {
val cause = ex.getCause match {
case ex: ExceptionInInitializerError => ex.getCause
Copy link
Contributor Author

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.

Copy link
Member

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it

@allanrenucci
Copy link
Contributor Author

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)

@allanrenucci allanrenucci changed the title Fix #3305 Fix #3305 and #3309 Oct 12, 2017
@smarter
Copy link
Member

smarter commented Oct 12, 2017

Also, the commit message titles could be improved to say what is being fixed, not just give the issue number.

@@ -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)
Copy link
Contributor Author

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)?

Copy link
Contributor

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 :)

Copy link
Contributor Author

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.
scala> }
1 | }
| ^
| eof expected, but '}' found
Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like it!

@allanrenucci allanrenucci merged commit a886cd4 into scala:master Oct 13, 2017
@allanrenucci allanrenucci deleted the fix-#3305 branch December 14, 2017 19:18
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

Successfully merging this pull request may close these issues.

3 participants