Skip to content

Commit

Permalink
Also allow real and boolean comparisons with null in Jass code (#1086)
Browse files Browse the repository at this point in the history
In addition to already allowing integer comparisons
  • Loading branch information
Frotty authored Jan 4, 2024
1 parent 8668904 commit dd9ac8a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
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

0 comments on commit dd9ac8a

Please sign in to comment.