haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Uninitialized Final Field Ignored When Using Macro in Haxe Compiler

Open NipponSunrise opened this issue 9 months ago • 4 comments
trafficstars

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)

NipponSunrise avatar Feb 21 '25 06:02 NipponSunrise