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 a238d9bc372ab5ae30992b4c3d1c6d2ec9bda44d
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Sep 17 14:34:37 2024 -0700

    MethodBodySemanticChecker: add missing warning for boolean comparison with 
null
    
    Similar for the existing check with undefined. Brings parity with Flex SDK 
compiler
---
 .../compiler/internal/semantics/MethodBodySemanticChecker.java      | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
index b7dbf37d2..17557a239 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
@@ -766,6 +766,8 @@ public class MethodBodySemanticChecker
         
         final boolean leftIsNumeric = SemanticUtils.isNumericType(left_type, 
project);
         final boolean rightIsNumeric = SemanticUtils.isNumericType(right_type, 
project);
+        final boolean leftIsNumericOrBoolean = 
SemanticUtils.isNumericTypeOrBoolean(left_type, project);
+        final boolean rightIsNumericOrBoolean = 
SemanticUtils.isNumericTypeOrBoolean(right_type, project);
         final boolean leftIsNull =  SemanticUtils.isBuiltin(left_type, 
BuiltinType.NULL, project);
         final boolean rightIsNull =  SemanticUtils.isBuiltin(right_type, 
BuiltinType.NULL, project);
         
@@ -779,8 +781,8 @@ public class MethodBodySemanticChecker
          
         boolean isBad = false;
         
-        // Numeric types can never be null
-        if ((leftIsNumeric&&rightIsNull) || (rightIsNumeric&&leftIsNull))
+        // Numeric and boolean types can never be null
+        if ((leftIsNumericOrBoolean&&rightIsNull) || 
(rightIsNumericOrBoolean&&leftIsNull))
         {
             isBad = true;
         }

Reply via email to