HaxeFoundation / HaxeFoundation/haxe

"Inline variable initialization must be a constant value" despite -D no-inline

Open
#10,779 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Consider the following Haxe code:

```haxe
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](https://github.com/HaxeFoundation/haxe/files/9389440/NoInlineIssue.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.