Build error for Array var declared as static inline

Going by the Haxe description of static inline vars, the following should be allowed:

public static inline var LIST:Array<String> = ["item1","item2","item3];

In the build, the line LIST.indexOf(i); would be replaced by [“item1”,“item2”,"item3].indexOf(i); which is allowed.

Does Haxe allow for this or is the problem that the compiler I’m using cannot handle it?

As a general rule, any value for which LIST == LIST doesn’t hold is not allowed there.

You can make the array final and read-only instead:

public static final LIST:haxe.ds.ReadOnlyArray<String> = ["item1","item2","item3"];

Why wouldn’t LIST == LIST hold?

That works, thanks. Had tried using get & set but that didn’t work either.

If inline is allowed you will get ["item1","item2","item3] == ["item1","item2","item3]; which is false

For haxe without Final or without ReadOnlyArray ( so slightly older Haxe ) you can use a function. Because I have inlined it the compiler will insert the String at the point were you call it - so you won’t have cost of the function call.

class Test {
    static function main() {
        trace( LIST() );
    }
    public static inline function LIST(){
        return ["item1","item2","item3"];
    }
}

generated JS

// Generated by Haxe 3.4.4
(function () { "use strict";
var Test = function() { };
Test.main = function() {
	console.log(["item1","item2","item3"]);
};
Test.main();
})();

Also you can access via a getter: