RealyUniqueName / Safety

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

Arrays of mixed types are only allowed if the type is forced to Array<Dynamic> #6

Open restorer opened 6 years ago

restorer commented 6 years ago
class Bug1 {
    public function bug() : Void {
        // Arrays of mixed types are only allowed if the type is forced to Array<Dynamic>
        // Bug in "safeArray"
        ["A", 1];
    }
}

See https://github.com/restorer/haxe-safety-bugs/blob/master/safetybugs/Main.hx#L43 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

This is not related to Safety. It's a pure Haxe behavior: http://try-haxe.mrcdk.com/#A3BF6

restorer commented 6 years ago

Sorry, bad example. I will provide correct example later.

RealyUniqueName commented 6 years ago

Feel free to reopen.

restorer commented 6 years ago

Correct example:

class Bug1Corrected {
    public function foo(a : Array<Dynamic>) : Void {
        trace(a);
    }

    public function bug() : Void {
        // Arrays of mixed types are only allowed if the type is forced to Array<Dynamic>
        // Bug in "safeArray"
        foo(["A", 1]);
    }
}

Test project: https://github.com/restorer/haxe-safety-bugs/blob/master/safetybugs/Main.hx#L207

Pure Haxe: http://try-haxe.mrcdk.com/#CdD25

P.S. Also either I don't know how to reopen issues on github 😄 or I doesn't have permissions for that.