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


The following commit(s) were added to refs/heads/develop by this push:
     new 06e46e5a2 MethodBodySemanticChecker: prevent 'arguments' binding from 
being used in an arrow function
06e46e5a2 is described below

commit 06e46e5a23bd532d25d7cfbfd1402aebd3a7cda6
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Jan 27 11:52:47 2026 -0800

    MethodBodySemanticChecker: prevent 'arguments' binding from being used in 
an arrow function
    
    Arrow functions aren't supposed to have their own this, super, or arguments 
bindings. The compiler already reports an error if this or super are used in 
contexts where they don't make sense. Report a similar error for arguments here.
---
 .../semantics/MethodBodySemanticChecker.java       |  5 +++
 .../ArgumentsUsedInArrowFunctionProblem.java       | 36 ++++++++++++++++++++++
 2 files changed, 41 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 642d4a7d9..e9bb165c2 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
@@ -1805,6 +1805,11 @@ public class MethodBodySemanticChecker
             FunctionDefinition functionDef = 
SemanticUtils.getFunctionDefinition(iNode);
             if (functionDef != null)
             {
+                IFunctionNode funcNode = functionDef.getFunctionNode();
+                if (funcNode != null && funcNode.isArrowFunction())
+                {
+                    addProblem(new ArgumentsUsedInArrowFunctionProblem(iNode));
+                }
                 ParameterDefinition[] parameters = functionDef.getParameters();
                 for (ParameterDefinition param : parameters)
                 {
diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/problems/ArgumentsUsedInArrowFunctionProblem.java
 
b/compiler/src/main/java/org/apache/royale/compiler/problems/ArgumentsUsedInArrowFunctionProblem.java
new file mode 100644
index 000000000..77d60ab96
--- /dev/null
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/problems/ArgumentsUsedInArrowFunctionProblem.java
@@ -0,0 +1,36 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.royale.compiler.problems;
+
+import org.apache.royale.compiler.tree.as.IASNode;
+
+public class ArgumentsUsedInArrowFunctionProblem extends StrictSemanticsProblem
+{
+    public static final String DESCRIPTION = "'${ARGUMENTS}' can not be used 
in arrow functions.";
+
+
+    public ArgumentsUsedInArrowFunctionProblem(IASNode site)
+    {
+        super(site);
+    }
+
+    // Protect these from being localized.
+    public final String ARGUMENTS = "arguments";
+}

Reply via email to