wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps
https://wurstlang.org
Apache License 2.0
226 stars 28 forks source link

Map crashes due to generated jass function with too many arguments #1072

Closed jlfarris91 closed 1 year ago

jlfarris91 commented 1 year ago

In Jass the max number of function arguments is 32 and there's a function being generated by Wurst that has 33.

Additionally, I can build the map multiple times in a row and get the same function generated differently each time - some with 33, some with 32.

Last Stand has this problem, not sure what I can do to help sort this out since building the project is a bit involved. Might help for the compiler to throw an exception when it tries to generate a function with more than 32 arguments.

Frotty commented 1 year ago

Can you post what functions are having so many parameters?

jlfarris91 commented 1 year ago

Bad compiled.j.txt Bad functions

jlfarris91 commented 1 year ago

It's odd to me that it's a different function complaining with each compile

Frotty commented 1 year ago

cyc_ indicates this function is used to resolve a cyclic dependency, which you ideally shouldn't have. So consider getting rid of any initlater in your packages. The cycle resolution might not be deterministic, which is why it is a different function on different compilations. Also it seems most parameters are coming from stacktraces, so turning them off should also get rid of the error. Additionally, the parameter amount seems to stem from using tuples for many things, which isn't ideal either. Consider using classes for data stuff. Other than updating pjass to detect this error I will not do anything regarding this issue, as it seems non trivial to solve in the compiler, but trivially to solve by the user. Another option is to use the lua backend, which doesn't have the same parameter limitations (but other limitations).

jlfarris91 commented 1 year ago

Oh great, I can give those suggestions a try. Thanks.

Tuples are terribly convenient.

jlfarris91 commented 1 year ago

I think it would be worth detecting any generated arguments that exceed the limit so that users don't waste time waiting for the game to launch before ultimately crashing.

Frotty commented 1 year ago

I updated pjass now to detect functions with too many parameters in jass output.