You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining a final variable in an interface, implementing it in an abstract class, and inheriting that abstract class in another class, we are expected to initialize the final variable either in the abstract class or the derived class. Otherwise, the compiler correctly throws an error:
Some final fields are uninitialized in this class
However, when using a macro that adds a new variable to the abstract class and invoking it via @:autoBuild(Macro.build()), the compiler fails to enforce initialization for the final variable defined in the interface. This results in an uninitialized final variable being accepted, which contradicts expected behavior.
Description
When defining a final variable in an interface, implementing it in an abstract class, and inheriting that abstract class in another class, we are expected to initialize the final variable either in the abstract class or the derived class. Otherwise, the compiler correctly throws an error:
Some final fields are uninitialized in this class
However, when using a macro that adds a new variable to the abstract class and invoking it via
@:autoBuild(Macro.build())
, the compiler fails to enforce initialization for the final variable defined in the interface. This results in an uninitialized final variable being accepted, which contradicts expected behavior.Steps to Reproduce
Reproduction Example in Haxe Sandbox
Expected Behavior
The compiler should enforce initialization of the final variable defined in the interface, regardless of the applied macro.
Actual Behavior
When the macro is applied, the compiler does not report an error for an uninitialized final variable.
Environment
Haxe Compiler Version:
4.3.6
Target Platform: JavaScript (others are not tested)
The text was updated successfully, but these errors were encountered: