RealyUniqueName / Safety

Null safety for Haxe
MIT License
54 stars 5 forks source link

Proposal: be less strict for single-thread environments #11

Closed restorer closed 6 years ago

restorer commented 6 years ago
class NotABugButProposal6 {
    private var s : Null<String>;

    public function proposal() : Void {
        s = ((Math.random() > 0.5) ? "A" : null);

        if (s != null) {
            // Safety: Cannot access "length" of a nullable value.
            // While it makes sense in case of multithreading, is it possible to add something like `@:safety(threadsafe)`?
            s.length;
        }
    }
}

See https://github.com/restorer/haxe-safety-bugs/blob/master/safetybugs/Main.hx#L95 for working example.

restorer commented 6 years ago

This is for Haxe 4.0.0-preview.5 and Safety from master.

RealyUniqueName commented 6 years ago

It's basically the same as https://github.com/RealyUniqueName/Safety/issues/15