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 0f9aafa232d11515c3ca65ca357605df5cc7f3ca Author: Josh Tynjala <[email protected]> AuthorDate: Tue Sep 17 13:22:57 2024 -0700 MethodBodySemanticChecker: similar to the warning when assigning null to numeric of boolean, issue warning if null is returned and the return type is numeric or boolean Improves parity with the Flex SDK compiler --- .../compiler/internal/semantics/MethodBodySemanticChecker.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 4eeceb957..b7dbf37d2 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 @@ -2624,6 +2624,14 @@ public class MethodBodySemanticChecker { checkImplicitConversion(returnExpression, return_type, null); } + + IDefinition rightType = returnExpression.resolveType(project); + final boolean leftIsNumericOrBoolean = SemanticUtils.isNumericTypeOrBoolean(return_type, project); + final boolean rightIsNull = SemanticUtils.isBuiltin(rightType, BuiltinType.NULL, project); + if (leftIsNumericOrBoolean && rightIsNull) + { + addProblem(new NullUsedWhereOtherExpectedProblem(returnExpression, return_type.getBaseName())); + } } catch ( Exception namerezo_problem ) {
