-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Exception throw when compiling a project: java.lang.NullPointerException: tried to cast away nullability, but value is null #15845
Comments
Yes, that's clearly a compiler bug. |
@OndrejSpanel if you run this on latest main once #15890 is merged you should hopefully get the compilation unit that caused the crash. |
To clarify how to proceed: does this mean I should test the issue on 3.1.4 once it is released? |
If you want to wait for a release it would be 3.2.1. But you could also run
with the nightly before. once #15845 is merged.
…On Sat, Aug 20, 2022 at 1:16 PM Ondřej Španěl ***@***.***> wrote:
if you run this on latest main
To clarify how to proceed: does this mean I should test the issue on 3.1.4
once it is released?
—
Reply to this email directly, view it on GitHub
<#15845 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGCKVUZZ66FY3AY5AEKAQDV2C47DANCNFSM56HDFLOA>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Martin Odersky
Professor, Programming Methods Group (LAMP)
Faculty IC, EPFL
Station 14, Lausanne, Switzerland
|
@OndrejSpanel can you try with scalaVersion |
Thanks for pinging me. When I have tried that, I am told which file is the error in, and that the error is while typechecking:
When I remove State.scala completely, I get a different error in a different file:
I will try removing a much as possible to still get the |
I was able to reduce the repro into two files, each of them containing only a few lines of code. Repro is available in https://github.com/OndrejSpanel/scala3-error-repro I was not able to reproduce the issue in a single file, or without a nested This is how the files currently look like: Config.scala: package config
package state
case class Config(simulations: Seq[(String, Any)] = Seq.empty) State.scala: package config
import state._
object State {
object Info {
def apply(): Info = Info(Config(), Seq.empty)
}
case class Info(cfg: AnyRef, allTypes: Seq[AnyRef])
} |
Thanks for minimization! I tried to reproduce it, but it works for me. Is there something unexpected on your classpath maybe? |
How can I check for that? I get the error by just launching I use Windows 11 x64, my default Java version is 11:
|
It it not Windows specific, it can be reproduced on a GitHub runner using Ubuntu, see https://github.com/OndrejSpanel/scala3-error-repro/runs/7954324298?check_suite_focus=true I think the GitHub runner environment should be clean and there should be no class-path issues on it. |
I could reproduce it now. The two files have to be compiled as State.scala and Config.scala, in that order on the command line. If the order is swapped, it compiles. I.e.
|
Fixes scala#15845. Curiously this code was never exercised before, despite the many millions of lines of code we compile. It's even more curious that the faulty behavior could be triggered by such a simple example.
Compiler version
3.1.3
Minimized example
I am afraid I do not have a minimized example yet, I will need some advice on how to extract it.
I am trying to port my complex project to Scala 3. I have fixed most deprecation warnings in 2.13 and upgraded almost all libraries. I am not getting much compiler errors any more, but still use both "-source:3.0-migration" and "-Xignore-scala2-macros", as not all libraries are ported and I still need to compile the project as 2.13 one.
Output
When building my project with Scala 3.1.3, I get following error:
I am not told which part of the project / what particulat Scala source is the compiler working at, therefore I have no idea how could I pinpoint the problem.
The top of the callstack is:
Expectation
I think compiler can show errors, but should never throw exceptions.
The text was updated successfully, but these errors were encountered: