Skip to content

Ingame errors with -lua #885

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

Closed
Jampi0n opened this issue Aug 13, 2019 · 4 comments
Closed

Ingame errors with -lua #885

Jampi0n opened this issue Aug 13, 2019 · 4 comments

Comments

@Jampi0n
Copy link
Contributor

Jampi0n commented Aug 13, 2019

I tried the -lua run argument in my map and it produced errors during the initialization. One of the issues I found is, that functions can return nil instead of the specified type, possibly leading to errors, when using the returned value.

code to reproduce: https://bin.wurstlang.org/ajosinetib.wurst

Could be related to #869

@Jampi0n
Copy link
Contributor Author

Jampi0n commented Feb 13, 2020

I managed to change my map, so it works in lua. The most prevalent issue is mentioned above. In particular this construct does not work:
let tmp = HashMap.get(key)
if tmp != null
This can be fixed using HashMap.has(key) before.

Additionally using null as string does not work.

For the first issue, there is likely no good solution, other than updating the code and check whether the key exists first.
I assume null strings can work by simply replacing null with "", when compiling to lua (is there a difference between null and "" in jass?)

The standard library uses the HashMap as shown above, so it can lead to issues. It also uses null as string, so at the moment FrameHandle.wurst cannot initialize.

@peq
Copy link
Collaborator

peq commented Feb 13, 2020

Thanks for the report.

The thing with nulls and strings is something I thought was working. We have some test cases testing different combinations of using null here:

@Test
public void stringPlusNull1() {
testAssertOkLines(true,
"package Test",
"native testSuccess()",
"function nullString() returns string",
" return null",
"init",
" var s = \"a\" + nullString()",
" if s == \"a\"",
" testSuccess()"
);
}
@Test
public void stringPlusNull2() {
testAssertOkLines(true,
"package Test",
"native testSuccess()",
"function nullString() returns string",
" return null",
"init",
" var s = nullString() + nullString()",
" if s == null",
" testSuccess()"
);
}
@Test
public void stringPlusNull3() {
testAssertOkLines(true,
"package Test",
"native testSuccess()",
"function nullString() returns string",
" return null",
"init",
" var s = nullString() + \"a\"",
" if s == \"a\"",
" testSuccess()"
);
}

Can you show an example where null as string does not work?

I'll also look at the HashMap problem. Maybe that will already fixed by the upcoming changes in #931 .

@Jampi0n
Copy link
Contributor Author

Jampi0n commented Feb 14, 2020

Using the FrameHandle package leads to an error, because it uses
let mouseCage = createFrame("FRAME", "SetMousePositionCage", GAME_UI, null, 0)
in line 389. Here, null is used as parameter for a native function that expects a string.

So using that package, you get an error with the string. For example with this code: https://bin.wurstlang.org/viyirecelo.wurst

On a related note, I found an issue when I tried to create a minimal example with the string problem.
If I add the imports NoWurst and Framehandle to minimize the produced code, the map doesn't start in lua mode (JASS works fine). I only get the screen with the lordaeron lion. Code: https://bin.wurstlang.org/epuhotezaj.wurst

@Frotty
Copy link
Member

Frotty commented Apr 4, 2022

seems resolved.

@Frotty Frotty closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants