comparison src/eval.c @ 28115:62a57c60edc1 v8.2.4582

patch 8.2.4582: useless code handling a type declaration Commit: https://github.com/vim/vim/commit/4c8b546da2059865e20902586bb3e0ff07c279a0 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 16 20:01:39 2022 +0000 patch 8.2.4582: useless code handling a type declaration Problem: Useless code handling a type declaration. Solution: Remove the code and give an error.
author Bram Moolenaar <Bram@vim.org>
date Wed, 16 Mar 2022 21:15:02 +0100
parents 710a509be2cd
children 57ea74314c1b
comparison
equal deleted inserted replaced
28114:8510390872d6 28115:62a57c60edc1
935 --p; 935 --p;
936 lp->ll_name_end = p; 936 lp->ll_name_end = p;
937 } 937 }
938 if (*p == ':') 938 if (*p == ':')
939 { 939 {
940 garray_T tmp_type_list;
941 garray_T *type_list;
942 char_u *tp = skipwhite(p + 1); 940 char_u *tp = skipwhite(p + 1);
943 941
944 if (tp == p + 1 && !quiet) 942 if (tp == p + 1 && !quiet)
945 { 943 {
946 semsg(_(e_white_space_required_after_str_str), ":", p); 944 semsg(_(e_white_space_required_after_str_str), ":", p);
947 return NULL; 945 return NULL;
948 } 946 }
949 947
950 if (SCRIPT_ID_VALID(current_sctx.sc_sid)) 948 if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
951 type_list = &SCRIPT_ITEM(current_sctx.sc_sid)->sn_type_list; 949 {
952 else 950 semsg(_(e_using_type_not_in_script_context_str), p);
953 { 951 return NULL;
954 // TODO: should we give an error here?
955 type_list = &tmp_type_list;
956 ga_init2(type_list, sizeof(type_T), 10);
957 } 952 }
958 953
959 // parse the type after the name 954 // parse the type after the name
960 lp->ll_type = parse_type(&tp, type_list, !quiet); 955 lp->ll_type = parse_type(&tp,
956 &SCRIPT_ITEM(current_sctx.sc_sid)->sn_type_list,
957 !quiet);
961 if (lp->ll_type == NULL && !quiet) 958 if (lp->ll_type == NULL && !quiet)
962 return NULL; 959 return NULL;
963 lp->ll_name_end = tp; 960 lp->ll_name_end = tp;
964
965 // drop the type when not in a script
966 if (type_list == &tmp_type_list)
967 {
968 lp->ll_type = NULL;
969 clear_type_list(type_list);
970 }
971 } 961 }
972 } 962 }
973 } 963 }
974 if (lp->ll_name == NULL) 964 if (lp->ll_name == NULL)
975 return p; 965 return p;