diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp
index 7c757922b8221ebdbe6ad0f01adccf1563d01ade..23a5f92808d75aea0e747a5c1593169b28ffd508 100644
--- a/ets2panda/checker/types/ets/etsFunctionType.cpp
+++ b/ets2panda/checker/types/ets/etsFunctionType.cpp
@@ -168,7 +168,7 @@ static Signature *EnhanceSignatureSubstitution(TypeRelation *relation, Signature
auto const enhance = [checker, sub, substitution](Type *param, Type *arg) {
return checker->EnhanceSubstitutionForType(sub->GetSignatureInfo()->typeParams, param, arg, substitution);
};
- for (size_t ix = 0; ix < super->MinArgCount(); ix++) {
+ for (size_t ix = 0; ix < sub->ArgCount(); ix++) {
if (!enhance(sub->GetSignatureInfo()->params[ix]->TsType(), super->GetSignatureInfo()->params[ix]->TsType())) {
return nullptr;
}
diff --git a/ets2panda/test/ast/compiler/ets/generic_callback.ets b/ets2panda/test/ast/compiler/ets/generic_callback.ets
new file mode 100644
index 0000000000000000000000000000000000000000..92c4b7ad7e8c7186666911d3e4c1f5ee1faa81f4
--- /dev/null
+++ b/ets2panda/test/ast/compiler/ets/generic_callback.ets
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed 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.
+ */
+
+ function identity(a: A): A {
+ return a;
+}
+let x = [1, 2, 3].map(identity)[0];
+
+/* @@? 19:9 Error TypeError: No matching call signature for map((a: A) => A) */
+/* @@? 19:9 Error TypeError: Indexed access is not supported for such expression type. */
+/* @@? 19:9 Error TypeError: No matching call signature for map((a: A) => A) */
+/* @@? 19:9 Error TypeError: Indexed access is not supported for such expression type. */
+/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Double, array: Array) => A' at index 1 */
+/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Double, array: ReadonlyArray) => A' at index 1 */
+/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Double, array: Array) => A' at index 1 */
+/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Double, array: ReadonlyArray) => A' at index 1 */