diff --git a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/types/WurstTypeNull.java b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/types/WurstTypeNull.java index 67b9390ae..98d0081e9 100644 --- a/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/types/WurstTypeNull.java +++ b/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/types/WurstTypeNull.java @@ -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; } diff --git a/de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/JurstTests.java b/de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/JurstTests.java index fe7f88e63..3b086e872 100644 --- a/de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/JurstTests.java +++ b/de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/JurstTests.java @@ -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"))));