Skip to content

Conversation

@Davvex87
Copy link

Read #45 for more information.

In short, static variables do not have their default expression passed through preprocessors like functions do, causing unintended behavior in certain classes.

The fix was basically just create a "virtual" ClassFuncData object and then pass that to the preprocessors, extract the final modified expr, do some final processing and overwrite the expr() function in the ClassVarData to return our fixed expression.

Fixes #45, I opened it 11 hours ago and I never expected to be able to fix this issue any time soon, guess I out-did myself, whoops...

Davvex87 added a commit to Davvex87/reflaxe.lua that referenced this pull request Dec 20, 2025
@SomeRanDev
Copy link
Owner

The static vars thing is a tough problem since it works differently for each target, but this a good start. I think how static variable assignments are transformed should be handled as a BaseCompilerOptions. Could you add a field to that (like convertStaticVarExpressionsToFunctions) and have it so this only runs if that's true?

Maybe I'm missing something, but dataProxy needs to be stored somewhere so Reflaxe compilers will use it right? I'm guessing you're overriding the ClassField expression since the ClassFuncData isn't stored, but I think instead of assigning the ClassField expression, we should store ClassFuncData with the other datas.

@Davvex87
Copy link
Author

I'm afraid some API needs to be changed in order to make this possible because preprocessors take the ClassFuncData class as an argument, that's also why I had to use a virtual ClassFuncData before. Thank you for the suggestions, I'll notify once everything is ready.

@Davvex87
Copy link
Author

Davvex87 commented Jan 1, 2026

Alrighty, I'd say it's ready. I've done some testing with https://github.com/Davvex87/reflaxe.lua/tree/feature/reflaxe-new-statics and it generates stuff as expected.

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

Successfully merging this pull request may close these issues.

Static variables with default value do not have their typed expression processed by expression preprocessors

2 participants