haxetink / tink_pure

Pure immutable data.
MIT License
10 stars 7 forks source link

Vector unifying with incompatible types #22

Closed kevinresol closed 3 years ago

kevinresol commented 3 years ago
class Main {
    static function main() {
        var foo:tink.pure.Vector<Foo> = [];
        var bar:tink.pure.Vector<Bar> = foo;
    }
}

typedef Foo = {
    final id:String;
    final ?project:String;
}

typedef Bar = {
    final id:String;
    final createDate:Date;
}

The above code compiles but it should not.

If we replace Vector with Array we will get:

src/Main.hx:4: characters 3-28 : error: { id : String, createDate : Date } has no field project
src/Main.hx:4: characters 3-28 : ... have: Array<Foo>
src/Main.hx:4: characters 3-28 : ... want: Array<Bar>
kevinresol commented 3 years ago

I think this is a Haxe issue