haxe
haxe copied to clipboard
"Inline variable initialization must be a constant value" despite -D no-inline
Consider the following Haxe code:
class Main {
public static inline var maxLightsCluster = getMaxLightsCluster();
static function main() {
trace(maxLightsCluster);
}
public static inline function getMaxLightsCluster(): Int {
#if (rp_max_lights_cluster == 8)
return 8;
#elseif (rp_max_lights_cluster == 16)
return 16;
#elseif (rp_max_lights_cluster == 32)
return 32;
#elseif (rp_max_lights_cluster == 64)
return 64;
#else
return 4;
#end
}
}
When compiling with -D no-inline
, there is the following error:
src/Main.hx:2: characters 2-68 : Inline variable initialization must be a constant value
Of course the getMaxLightsCluster()
function is no longer inlined, but the variable maxLightsCluster
shouldn't be inlined anymore as well. The manual does not state that the no-inline
option only considers functions, but not variables.
I'm using Haxe 4.2.5.
VSCode example project (try.haxe.org has no no-inline
param):
NoInlineIssue.zip