static initialisation order loop
Consider following code:
// Test.hx
import Test2;
final FOO = "FOO";
final BARFOO = BAR + FOO;
function main() {
trace('$FOOBAR $BARFOO');
}
// Test2.hx
import Test;
final BAR = "BAR";
final FOOBAR = FOO + BAR;
It will output something like "nullBAR FOOBAR" or "undefindBAR BARFOO".
I believe it should either output "FOOBAR BARFOO" or give a compilation error.
When running with eval it will give warning: "Warning : maybe loop in static generation". Which is great, but I think we need such warning for all platforms and I think this should be compilation error instead of warning.
https://try.haxe.org/#F6b211C6
I have run into cases where the warning was emitted, even though nothing actually went wrong. It should not be a compilation error unless it is made more reliable.
This does give a warning on all targets. Please note that on try.haxe you might find it in the "Compiler output" tab. Eval is probably a special case in this regard because compiler output and run-time output are pretty much the same.
And I agree that a warning is better for this. However, now that we have a proper warning system, we could look into adding an option to turn specific warnings into errors. That's a story for another day/issue though.