Mercurial > vim
comparison src/vim9script.c @ 23917:4b417b776b95 v8.2.2501
patch 8.2.2501: not always clear where an error is reported
Commit: https://github.com/vim/vim/commit/f785aa1354208f6b644e891aa01f8f86d947af7e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 11 21:19:34 2021 +0100
patch 8.2.2501: not always clear where an error is reported
Problem: Not always clear where an error is reported.
Solution: Add the where_T structure and pass it around. (closes https://github.com/vim/vim/issues/7796)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 11 Feb 2021 21:30:04 +0100 |
parents | 85cf06ddb2a8 |
children | 39cf2d8e7edf |
comparison
equal
deleted
inserted
replaced
23916:cdb1a04f8189 | 23917:4b417b776b95 |
---|---|
648 if (type->tt_type == VAR_ANY) | 648 if (type->tt_type == VAR_ANY) |
649 // A variable of type "any" is not possible, just use zero instead | 649 // A variable of type "any" is not possible, just use zero instead |
650 init_tv.v_type = VAR_NUMBER; | 650 init_tv.v_type = VAR_NUMBER; |
651 else | 651 else |
652 init_tv.v_type = type->tt_type; | 652 init_tv.v_type = type->tt_type; |
653 set_var_const(name, type, &init_tv, FALSE, 0); | 653 set_var_const(name, type, &init_tv, FALSE, 0, 0); |
654 | 654 |
655 vim_free(name); | 655 vim_free(name); |
656 return p; | 656 return p; |
657 } | 657 } |
658 | 658 |
853 // If "sv_name" is NULL the variable was hidden when leaving a block, | 853 // If "sv_name" is NULL the variable was hidden when leaving a block, |
854 // don't check "sv_tv" then, it might be used for another variable now. | 854 // don't check "sv_tv" then, it might be used for another variable now. |
855 if (sv->sv_name != NULL && sv->sv_tv == dest) | 855 if (sv->sv_name != NULL && sv->sv_tv == dest) |
856 return sv; | 856 return sv; |
857 } | 857 } |
858 iemsg("check_script_var_type(): not found"); | 858 iemsg("find_typval_in_script(): not found"); |
859 return NULL; | 859 return NULL; |
860 } | 860 } |
861 | 861 |
862 /* | 862 /* |
863 * Check if the type of script variable "dest" allows assigning "value". | 863 * Check if the type of script variable "dest" allows assigning "value". |
864 * If needed convert "value" to a bool. | 864 * If needed convert "value" to a bool. |
865 */ | 865 */ |
866 int | 866 int |
867 check_script_var_type(typval_T *dest, typval_T *value, char_u *name) | 867 check_script_var_type( |
868 typval_T *dest, | |
869 typval_T *value, | |
870 char_u *name, | |
871 where_T where) | |
868 { | 872 { |
869 svar_T *sv = find_typval_in_script(dest); | 873 svar_T *sv = find_typval_in_script(dest); |
870 int ret; | 874 int ret; |
871 | 875 |
872 if (sv != NULL) | 876 if (sv != NULL) |
874 if (sv->sv_const != 0) | 878 if (sv->sv_const != 0) |
875 { | 879 { |
876 semsg(_(e_readonlyvar), name); | 880 semsg(_(e_readonlyvar), name); |
877 return FAIL; | 881 return FAIL; |
878 } | 882 } |
879 ret = check_typval_type(sv->sv_type, value, 0); | 883 ret = check_typval_type(sv->sv_type, value, where); |
880 if (ret == OK && need_convert_to_bool(sv->sv_type, value)) | 884 if (ret == OK && need_convert_to_bool(sv->sv_type, value)) |
881 { | 885 { |
882 int val = tv2bool(value); | 886 int val = tv2bool(value); |
883 | 887 |
884 clear_tv(value); | 888 clear_tv(value); |