HaxeFoundation / HaxeFoundation/haxe

[null-safety] final vs. constructor throw

Open
#12,560 0 comments 1 reaction 2 assignees Claimed by @Simn View on GitHub
feature-null-safety
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
class C {
final s:String;

public function new() {
if (Math.random() > 0.5) {
throw "no";
} else {
s = "foo";
}
}
}
```

`Null safety: Field "s" is not nullable thus should have an initial value or should be initialized in constructor.`

This is not accurate because _if_ we get an object from the constructor the field will be assigned to.

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.