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 048ac1eb2c3ec4d12cbf95156f7ff7edf7f1b736 Author: Josh Tynjala <[email protected]> AuthorDate: Tue Sep 17 14:00:59 2024 -0700 ConstantLogic: warn when comparing a Number or int literal to null --- .../compiler/internal/as/codegen/ConstantLogic.jbg | 22 ++++++++++++++++++++++ 1 file changed, 22 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 33ddd3072..d39326333 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 @@ -93,6 +93,28 @@ return ECMASupport.equals(l, r); } + boolean_constant= + Op_EqualID(numeric_constant l, constant_value r) : 0 + { + if (r == NULL_VALUE) + { + String numberType = l instanceof Integer ? "int" : "Number"; + recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, numberType, "null")); + } + return ECMASupport.equals(l, r); + } + + boolean_constant= + Op_EqualID(constant_value l, numeric_constant r) : 0 + { + if (l == NULL_VALUE) + { + String numberType = r instanceof Integer ? "int" : "Number"; + recordError(new ComparisonBetweenUnrelatedTypesProblem(__p, numberType, "null")); + } + return ECMASupport.equals(l, r); + } + boolean_constant= Op_EqualID(constant_value l, constant_value r): 0 {
