Skip to content

crash on compilable code: NullPointerException #1703

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

Closed
helloqirun opened this issue Nov 13, 2016 · 3 comments
Closed

crash on compilable code: NullPointerException #1703

helloqirun opened this issue Nov 13, 2016 · 3 comments

Comments

@helloqirun
Copy link

scalac compiles but dotc crashes.

$ cat abc.scala

class DuplicateClassName { () => {
  { () =>
    }
}
}

$ dotc abc.scala

-- Error: abc.scala ----------------------------------------------------------------------------------------------------
1 |class DuplicateClassName { () => {
  |                           ^^
  |                           not a legal self type clause

exception occurred while typechecking abc.scala

exception occurred while compiling abc.scala
Exception in thread "main" java.lang.NullPointerException
	at dotty.tools.dotc.ast.tpd$.ref(tpd.scala:321)
	at dotty.tools.dotc.ast.untpd$.ref(untpd.scala:319)
	at dotty.tools.dotc.ast.desugar$.apply(Desugar.scala:936)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1478)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1484)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1494)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1492)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:132)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
<snipped>
@helloqirun
Copy link
Author

A more clean code example:

class Foo { () => 0 }

@liufengyun
Copy link
Contributor

Thanks for reporting @helloqirun .

This issue is related to #1683 and #1424 . We've decided to treat the code as a syntactical error, as @odersky commented here:

I think we should not try to overengineer fixing this. The scalac code doing this is quite impenetrable. I think "not a legal self type clause" is perfectly fine as an error message.

@liufengyun
Copy link
Contributor

Reopen, as we need to fix the crash.

@liufengyun liufengyun reopened this Nov 13, 2016
odersky added a commit to dotty-staging/dotty that referenced this issue Nov 16, 2016
Since self types are critical we should only install
one if it is syntactcally correct.

Fixes scala#1703.
@odersky odersky mentioned this issue Nov 16, 2016
@odersky odersky self-assigned this Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants