HaxeFoundation / HaxeFoundation/haxe

Null safety error for iterating on nullable could be improved

Open
#9,634 0 comments 0 reactions 0 assignees View on GitHub
enhancement error-reporting feature-null-safety
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
@:nullSafety class Main {
static var a:Null>;

static function main() {
for (i in a) {}
}
}
```

```
source/Main.hx:5: characters 3-18 : Null safety: Cannot perform array access on nullable value.
source/Main.hx:5: characters 3-18 : Null safety: Cannot access "length" of a nullable value.
```

The errors are slightly confusing, because the user is not actually perfoming array access or accessing `length` in that line. "Cannot iterate on nullable value" would be better.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.