HaxeFoundation / HaxeFoundation/haxe
[nullsafety] field access false positive with multiple guards
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Shouldn't this compile with loose null safety? Neither `a1` nor `a2` can be `null` here due to the previous checks:
```haxe
@:nullSafety
class Main {
static function main() {}
public static function equals(a1:Null>, a2:Null>):Bool {
if (a1 == null && a2 == null) return true;
if (a1 == null && a2 != null) return false;
if (a1 != null && a2 == null) return false;
if (a1.length != a2.length) return false;
// ...
return true;
}
}
```
```
source/Main.hx:9: characters 7-16 : Null safety: Cannot access "length" of a nullable value.
source/Main.hx:9: characters 20-29 : Null safety: Cannot access "length" of a nullable value.
```
Contributor guide
Assessment
This issue has not been assessed yet.