HaxeFoundation / HaxeFoundation/haxe
Assertion function/exception does not satisfy null safety
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
**Minimal reproduction of this issue:** https://try.haxe.org/#Cb6cD3c8
**Expected behavior:** Since `Assert.isNotNull()` throws an exception, which is caught and handled by the try/catch block, `takesNotNull()` will never be reached if `input` is null, thus null safety should be satisfied. However, the compiler provides the following:
```
[ERROR] Test.hx:24: characters 19-24
24 | takesNotNull(input);
| ^^^^^
| Null safety: Cannot pass nullable value to not-nullable argument "input" of function "takesNotNull".
```
**Application/Use case:** The example above is from when I was implementing a set of unit tests for my application, and I annotated them with `@:nullSafety` with the expectation that `Assert.isNotNull` would be recognized as a null safety sentinel.
Contributor guide
Assessment
This issue has not been assessed yet.