-
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
-Yexplicit-nulls fails to detect null pointer dereference #21380
Comments
Here's a simpler test that also fails (i.e. compiles successfully even though it shouldn't): @main def test() = {
var x: String | Null = null
x = ""
1 match {
case 1 => x = null
}
x.replace("", "") // error
} The problem is an inherent flaw in #18206. Before #18206, the compiler gives up analyzing any variable that has any assignments under |
@theosotr @noti0na1 side note: issues related to |
-Yexplicit-nulls
fails to detect method call on a variable holdingnull
.This might be regression, as
scalac
v3.3.3 detects the error as expected.Compiler version
3.4.2
Minimized code
Output
The code compiles with
-Yexplicit-nulls
, but at runtime you get NPEExpectation
The code should have been rejected with
The text was updated successfully, but these errors were encountered: