diff src/vim9type.c @ 25425:effe5f2b4d01 v8.2.3249

patch 8.2.3249: Vim9: error for re-imported function with default argument Commit: https://github.com/vim/vim/commit/60dc8274e9f8c6a20d54efebc7a8752fe062eead Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 29 22:48:54 2021 +0200 patch 8.2.3249: Vim9: error for re-imported function with default argument Problem: Vim9: error for re-imported function with default argument. Solution: Do not check argument type if it is still unknown. (closes https://github.com/vim/vim/issues/8653)
author Bram Moolenaar <Bram@vim.org>
date Thu, 29 Jul 2021 23:00:04 +0200
parents cfbf40f749b0
children b8a6a0007dc3
line wrap: on
line diff
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -954,9 +954,11 @@ parse_type(char_u **arg, garray_T *type_
 
 /*
  * Check if "type1" and "type2" are exactly the same.
+ * "flags" can have ETYPE_ARG_UNKNOWN, which means that an unknown argument
+ * type in "type1" is accepted.
  */
     int
-equal_type(type_T *type1, type_T *type2)
+equal_type(type_T *type1, type_T *type2, int flags)
 {
     int i;
 
@@ -981,17 +983,19 @@ equal_type(type_T *type1, type_T *type2)
 	    break;  // not composite is always OK
 	case VAR_LIST:
 	case VAR_DICT:
-	    return equal_type(type1->tt_member, type2->tt_member);
+	    return equal_type(type1->tt_member, type2->tt_member, flags);
 	case VAR_FUNC:
 	case VAR_PARTIAL:
-	    if (!equal_type(type1->tt_member, type2->tt_member)
+	    if (!equal_type(type1->tt_member, type2->tt_member, flags)
 		    || type1->tt_argcount != type2->tt_argcount)
 		return FALSE;
 	    if (type1->tt_argcount < 0
 			   || type1->tt_args == NULL || type2->tt_args == NULL)
 		return TRUE;
 	    for (i = 0; i < type1->tt_argcount; ++i)
-		if (!equal_type(type1->tt_args[i], type2->tt_args[i]))
+		if ((flags & ETYPE_ARG_UNKNOWN) == 0
+			&& !equal_type(type1->tt_args[i], type2->tt_args[i],
+									flags))
 		    return FALSE;
 	    return TRUE;
     }
@@ -1005,7 +1009,7 @@ equal_type(type_T *type1, type_T *type2)
     void
 common_type(type_T *type1, type_T *type2, type_T **dest, garray_T *type_gap)
 {
-    if (equal_type(type1, type2))
+    if (equal_type(type1, type2, 0))
     {
 	*dest = type1;
 	return;