HaxeFoundation / HaxeFoundation/haxe
[null-safety] if vs. ?.
Open
feature-null-safety
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```haxe
class C {
public function new() {}
public function isTrue() {
return true;
}
}
final c:Null = new C();
function main() {
if (c != null && c.isTrue()) {}
if (c?.isTrue()) {}
}
```
`Null safety: Cannot use nullable value as condition in "if".`
This might be a bit of a special case, but I'd expect the second version to be equivalent to the first one. Probably needs fixing at the typing stage already because if it's generating `if (c == null ? null : c.isTrue())` then I understand why null-safety would complain.
Contributor guide
Assessment
This issue has not been assessed yet.