HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit

Home Page:https://haxe.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@:structInit with getter+setter won't compile

rcstuber opened this issue · comments

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!

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