This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 76bfffd0d037ae4e14782f25ac3d2e6771cf4d9b
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Sep 17 14:15:12 2024 -0700

    ConstantLogic: missing null and undefined warnings for constants in not 
equals, strict not equals, less than, less than or equal, greater than, or 
greater than or equal
---
 .../compiler/internal/as/codegen/ConstantLogic.jbg | 180 +++++++++++++++++++++
 1 file changed, 180 insertions(+)

diff --git 
a/compiler/src/main/jburg/org/apache/royale/compiler/internal/as/codegen/ConstantLogic.jbg
 
b/compiler/src/main/jburg/org/apache/royale/compiler/internal/as/codegen/ConstantLogic.jbg
index 8fa0f86e5..02126269f 100644
--- 
a/compiler/src/main/jburg/org/apache/royale/compiler/internal/as/codegen/ConstantLogic.jbg
+++ 
b/compiler/src/main/jburg/org/apache/royale/compiler/internal/as/codegen/ConstantLogic.jbg
@@ -204,6 +204,36 @@
      return !ECMASupport.equals(l, r);
  }
 
+ boolean_constant=
+ Op_NotEqualID(numeric_constant l, constant_value r) : 0
+ {
+    if (r == NULL_VALUE)
+    {
+        String numberType = l instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (r == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return !ECMASupport.equals(l, r);
+ }
+
+ boolean_constant=
+ Op_NotEqualID(constant_value l, numeric_constant r) : 0
+ {
+    if (l == NULL_VALUE)
+    {
+        String numberType = r instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (l == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return !ECMASupport.equals(l, r);
+ }
+
  boolean_constant=
  Op_NotEqualID(constant_value l, constant_value r): 0
  {
@@ -230,6 +260,36 @@
      return !ECMASupport.equals(l, r);
  }
 
+ boolean_constant=
+ Op_StrictNotEqualID(numeric_constant l, constant_value r) : 0
+ {
+    if (r == NULL_VALUE)
+    {
+        String numberType = l instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (r == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return !ECMASupport.strictEquals(l, r);
+ }
+
+ boolean_constant=
+ Op_StrictNotEqualID(constant_value l, numeric_constant r) : 0
+ {
+    if (l == NULL_VALUE)
+    {
+        String numberType = r instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (l == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return !ECMASupport.strictEquals(l, r);
+ }
+
  boolean_constant=
  Op_StrictNotEqualID(constant_value l, constant_value r): 0
  {
@@ -242,6 +302,36 @@
       return ECMASupport.lessThan(l, r);
  }
 
+ boolean_constant=
+ Op_LessThanID(numeric_constant l, constant_value r) : 0
+ {
+    if (r == NULL_VALUE)
+    {
+        String numberType = l instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (r == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.lessThan(l, r);
+ }
+
+ boolean_constant=
+ Op_LessThanID(constant_value l, numeric_constant r) : 0
+ {
+    if (l == NULL_VALUE)
+    {
+        String numberType = r instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (l == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.lessThan(l, r);
+ }
+
  boolean_constant=
  Op_LessThanID(constant_value l, constant_value r): 0
  {
@@ -254,6 +344,36 @@
       return ECMASupport.lessThanEquals(l, r);
  }
 
+ boolean_constant=
+ Op_LessThanEqualsID(numeric_constant l, constant_value r) : 0
+ {
+    if (r == NULL_VALUE)
+    {
+        String numberType = l instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (r == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.lessThanEquals(l, r);
+ }
+
+ boolean_constant=
+ Op_LessThanEqualsID(constant_value l, numeric_constant r) : 0
+ {
+    if (l == NULL_VALUE)
+    {
+        String numberType = r instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (l == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.lessThanEquals(l, r);
+ }
+
  boolean_constant=
  Op_LessThanEqualsID(constant_value l, constant_value r): 0
  {
@@ -266,6 +386,36 @@
       return ECMASupport.greaterThan(l, r);
  }
 
+ boolean_constant=
+ Op_GreaterThanID(numeric_constant l, constant_value r) : 0
+ {
+    if (r == NULL_VALUE)
+    {
+        String numberType = l instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (r == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.greaterThan(l, r);
+ }
+
+ boolean_constant=
+ Op_GreaterThanID(constant_value l, numeric_constant r) : 0
+ {
+    if (l == NULL_VALUE)
+    {
+        String numberType = r instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (l == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.greaterThan(l, r);
+ }
+
  boolean_constant=
  Op_GreaterThanID(constant_value l, constant_value r): 0
  {
@@ -278,6 +428,36 @@
       return ECMASupport.greaterThanEquals(l, r);
  }
 
+ boolean_constant=
+ Op_GreaterThanEqualsID(numeric_constant l, constant_value r) : 0
+ {
+    if (r == NULL_VALUE)
+    {
+        String numberType = l instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (r == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.greaterThanEquals(l, r);
+ }
+
+ boolean_constant=
+ Op_GreaterThanEqualsID(constant_value l, numeric_constant r) : 0
+ {
+    if (l == NULL_VALUE)
+    {
+        String numberType = r instanceof Integer ? "int" : "Number";
+        recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, 
numberType, "null"));
+    }
+    if (l == UNDEFINED_VALUE)
+    {
+        recordError(new IllogicalComparisonWithUndefinedProblem(__p));
+    }
+     return ECMASupport.greaterThanEquals(l, r);
+ }
+
  boolean_constant=
  Op_GreaterThanEqualsID(constant_value l, constant_value r): 0
  {

Reply via email to