HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.03k stars 648 forks source link

@:structInit with getter+setter won't compile #11661

Closed rcstuber closed 1 month ago

rcstuber commented 1 month ago

TryHaxe: https://try.haxe.org/#adC36E0e

@:structInit
class Foo {
    public var bar(get, set):String;

    function get_bar()
        return "bar";
    function set_bar(v)
    return v;
}

class Test {
    static function main() {
        var foo : Foo = {}; // error: "Object requires field bar"
    }
}

This won't compile, as it complains that the field bar is required. Since it's not a real field, this shouldn't happen though. Thanks in advance!

rcstuber commented 1 month ago

Thanks a lot @Apprentice-Alchemist for the fast fix and @Simn for merging!