Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
25424:3cf272d6ee04 | 25425:effe5f2b4d01 |
---|---|
952 return NULL; | 952 return NULL; |
953 } | 953 } |
954 | 954 |
955 /* | 955 /* |
956 * Check if "type1" and "type2" are exactly the same. | 956 * Check if "type1" and "type2" are exactly the same. |
957 * "flags" can have ETYPE_ARG_UNKNOWN, which means that an unknown argument | |
958 * type in "type1" is accepted. | |
957 */ | 959 */ |
958 int | 960 int |
959 equal_type(type_T *type1, type_T *type2) | 961 equal_type(type_T *type1, type_T *type2, int flags) |
960 { | 962 { |
961 int i; | 963 int i; |
962 | 964 |
963 if (type1 == NULL || type2 == NULL) | 965 if (type1 == NULL || type2 == NULL) |
964 return FALSE; | 966 return FALSE; |
979 case VAR_CHANNEL: | 981 case VAR_CHANNEL: |
980 case VAR_INSTR: | 982 case VAR_INSTR: |
981 break; // not composite is always OK | 983 break; // not composite is always OK |
982 case VAR_LIST: | 984 case VAR_LIST: |
983 case VAR_DICT: | 985 case VAR_DICT: |
984 return equal_type(type1->tt_member, type2->tt_member); | 986 return equal_type(type1->tt_member, type2->tt_member, flags); |
985 case VAR_FUNC: | 987 case VAR_FUNC: |
986 case VAR_PARTIAL: | 988 case VAR_PARTIAL: |
987 if (!equal_type(type1->tt_member, type2->tt_member) | 989 if (!equal_type(type1->tt_member, type2->tt_member, flags) |
988 || type1->tt_argcount != type2->tt_argcount) | 990 || type1->tt_argcount != type2->tt_argcount) |
989 return FALSE; | 991 return FALSE; |
990 if (type1->tt_argcount < 0 | 992 if (type1->tt_argcount < 0 |
991 || type1->tt_args == NULL || type2->tt_args == NULL) | 993 || type1->tt_args == NULL || type2->tt_args == NULL) |
992 return TRUE; | 994 return TRUE; |
993 for (i = 0; i < type1->tt_argcount; ++i) | 995 for (i = 0; i < type1->tt_argcount; ++i) |
994 if (!equal_type(type1->tt_args[i], type2->tt_args[i])) | 996 if ((flags & ETYPE_ARG_UNKNOWN) == 0 |
997 && !equal_type(type1->tt_args[i], type2->tt_args[i], | |
998 flags)) | |
995 return FALSE; | 999 return FALSE; |
996 return TRUE; | 1000 return TRUE; |
997 } | 1001 } |
998 return TRUE; | 1002 return TRUE; |
999 } | 1003 } |
1003 * "type2" and "dest" may be the same. | 1007 * "type2" and "dest" may be the same. |
1004 */ | 1008 */ |
1005 void | 1009 void |
1006 common_type(type_T *type1, type_T *type2, type_T **dest, garray_T *type_gap) | 1010 common_type(type_T *type1, type_T *type2, type_T **dest, garray_T *type_gap) |
1007 { | 1011 { |
1008 if (equal_type(type1, type2)) | 1012 if (equal_type(type1, type2, 0)) |
1009 { | 1013 { |
1010 *dest = type1; | 1014 *dest = type1; |
1011 return; | 1015 return; |
1012 } | 1016 } |
1013 | 1017 |