Skip to content

Fix #3703: Various fixes to make printing more robust in face of errors #3705

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 4 commits into from
Jan 27, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 28, 2017

No description provided.

@odersky
Copy link
Contributor Author

odersky commented Dec 28, 2017

There is still an issue in that the test file neg/i3703.scala should compile (at least scalac compiles it), but doesn't. It looks like a bad interaction of hk type inference with F-bounded polymorphism. We should come back to this at some point.

@odersky odersky requested a review from allanrenucci December 30, 2017 08:48
Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

@odersky Both added test cases now compile on master without the changes in this PR. Do you still want to merge the changes?

@odersky
Copy link
Contributor Author

odersky commented Jan 13, 2018

@allanrenucci Yes, these were some random problems encountered when playing with diagnostics while trying to understand previous bugs.

if (ctx.settings.uniqid.value) "#" + pt.hashCode else ""
if (ctx.settings.uniqid.value)
try "#" + pt.hashCode
catch { case ex: NullPointerException => "" }
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we do a null check first instead of catching NullPointerException ? This is fishy in general and is also not something that can be done on Scala.js by default (https://www.scala-js.org/doc/semantics.html)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, hashCode is computed, the null could be in a referenced type.

def refTxt =
try toTextGlobal(tp.ref)
catch {
case ex: Throwable => Str("...")
Copy link
Member

Choose a reason for hiding this comment

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

Is this just to catch infinite loops in LazyRefs? If so I'd just catch StackOverflowException, though I think it'd be cleaner to do loop detection in LazyRef#ref.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's to detect stack overflows. Evaluation of LazyRefs is not tail-recursive, so we will always get a stack overflow. Maybe we can do a better job in loop detection but I believe the two issues are separate.

It succeeds now, still worth keeping.
@odersky odersky merged commit bdf5d80 into scala:master Jan 27, 2018
@allanrenucci allanrenucci deleted the fix-#3703 branch January 27, 2018 15:41
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