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

Also allow real and boolean comparisons with null in Jass code #1086

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ public class WurstTypeNull extends WurstType {

private static final WurstTypeNull instance = new WurstTypeNull();

private WurstTypeNull() { }
private WurstTypeNull() {
}

@Override
VariableBinding matchAgainstSupertypeIntern(WurstType other, @Nullable Element location, VariableBinding mapping,
VariablePosition variablePosition) {
VariablePosition variablePosition) {
if (other.isNullable()) {
return mapping;
}
if (Utils.isJassCode(location)
&& (other instanceof WurstTypeInt || other instanceof WurstTypeIntLiteral)) {
if (Utils.isJassCode(location) &&
(other instanceof WurstTypeInt
|| other instanceof WurstTypeIntLiteral
|| other instanceof WurstTypeReal
|| other instanceof WurstTypeBool)) {
return mapping;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,25 @@ public void jassAgentTypeComparison() {
testJurstWithJass(true, true, jassCode, jurstCode);
}

@Test
public void jassRealToNullComparison() {
String jassCode = Utils.string(
"function bar takes real r returns boolean",
"return r == null",
"endfunction\n");


String jurstCode = Utils.string(
"package test",
" init",
" bar(0)",
" testSuccess()",
" end",
"endpackage");

testJurstWithJass(true, true, jassCode, jurstCode);
}

@Test
public void testBigJassScript() throws IOException {
String jassCode = new String(Files.readAllBytes(Paths.get(Utils.getResourceFile("test.j"))));
Expand Down