-
Notifications
You must be signed in to change notification settings - Fork 29
fix lua null string #995
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
fix lua null string #995
Conversation
replaces null strings with empty strings in lua
Hey, thanks for the lua PRs. Could you add unit tests for them? |
How would these unit tests look like? |
Yes, tests output the program states into files which you parse (test-output). |
I have some test cases, but I had to change WurstScriptTest.java to get lua compilation to work. In line 246. Is there a reason why lua is only tested if executeProg is true? executeProg is a parameter for translateAndTestLua, so it seems unnecessary to put it in the if. It would also be nice to have withStdLib for lua as well. I removed executeProg from the if and the tests work now, but I don't want to commit it, because there are probably reasons why it was put like this. |
It seems fine to me since executeProg is handled in the lua compile method. |
I changed the if to only check for lua. I added tests to verify that both lua execution and using standard library work. Edit: the two tests that fail are the ones which execute lua, so they require a lua installation |
Nice, sounds goo so far. |
I don't know much about docker, so I guess just remove the tests for now. Should I leave the functions in and just remove the test annotation or remove the function as well? Are you referring to the hashtable issue in #885 ? If the cast is moved outside from the HashMap.get function to its call, the desired return type is known and nil could be changed to the correct default value. In JASS the cast is also done at the call and different functions are used to cast the integer to the correct type. |
Don't remove anything, you can mark tests as ignored. What exactly doesn't work tho regarding to lua?
I don't really get the issue, so dunno. |
The error is that it cannot find a lua installation: The hashtable issue is more of a typecasting issue in lua and it affects some other parts as well. As an example, take the JASS HashMap: In lua, the HashMap function takes and returns values of unkown type and they are cast to integer inside the function:
The JASS approach has the advantage, that different cast functions can be used depending on the type. Currently there are other issues that are also related to typecasting in lua: String concatenation may not be used, if one of the operands is returned by a function that returns not just strings:
The plus operator in the last line is not translated to string concatenation, because the return type of strMap.get is any. Functions with type parameters are not translated correctly (the new commaList implementation does not work in lua because it uses LinkedList.map
In this example, the closure implementations are translated correctly, so the fist closure is just These errors can easily be avoided by changing the wurst code a little bit. So I don't know if it's worth trying to fix them, considering it will probably be a lot of work and the new generics should fix the problems anyway. |
Yeah so this could be fixed with a docker image that has a java and a lua installation. Regarding the rest, I think this was one of the reasons for the new typeclasses feature and new generics, which wouldn't rely on toIndex/fromIndex hacks anymore. |
LGTM, thanks 👍 |
replaces null strings with empty strings in lua
Null strings will cause errors when used in lua natives.
Fixes one of the issues reported in #885 .