Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Params const optimization is not a constant in all cases #14

Closed
dedmen opened this issue Sep 3, 2021 · 1 comment
Closed

Params const optimization is not a constant in all cases #14

dedmen opened this issue Sep 3, 2021 · 1 comment

Comments

@dedmen
Copy link
Owner

dedmen commented Sep 3, 2021

params ["_unit", "_pos", ["_target", objNull], ["_buildings", []]];
_buildings pushBack [1,2,3];

Compiles fine.
But after first run, assembly prints this

push ["_unit","_pos",["_target",<NULL-object>],["_buildings",[[1,2,3]]]]
callFunction params;

pushBack modified the reference inside the compiled script.
Need to insert + operator call between the const array and params call, if the default values contain an array because otherwise the array will leak into the script.

https://github.com/dedmen/ArmaScriptCompiler/blob/master/src/optimizer/optimizerModuleConstantFold.cpp#L230

@dedmen
Copy link
Owner Author

dedmen commented Sep 9, 2021

Fixed in b2d55a6

@dedmen dedmen closed this as completed Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant