comparison src/evalvars.c @ 27108:92e2e96ff559 v8.2.4083

patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable Commit: https://github.com/vim/vim/commit/0e3e7ba05fa9cebe17d38def97ecd38a987d02ec Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 13 20:18:56 2022 +0000 patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable Problem: Vim9: no test for "vim9script autoload' and using script variable in the same script. Solution: Add a simple test. Fix uncovered problem.
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Jan 2022 21:30:04 +0100
parents 140102677c12
children 62b88e6cd791
comparison
equal deleted inserted replaced
27107:6318e5d19095 27108:92e2e96ff559
2872 return ret; 2872 return ret;
2873 } 2873 }
2874 } 2874 }
2875 } 2875 }
2876 2876
2877 // When using "vim9script autoload" script-local items are prefixed but can
2878 // be used with s:name.
2879 if (SCRIPT_ID_VALID(current_sctx.sc_sid)
2880 && name[0] == 's' && name[1] == ':')
2881 {
2882 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
2883
2884 if (si->sn_autoload_prefix != NULL)
2885 {
2886 char_u *auto_name = concat_str(si->sn_autoload_prefix, name + 2);
2887
2888 if (auto_name != NULL)
2889 {
2890 ht = &globvarht;
2891 ret = find_var_in_ht(ht, *name, auto_name, TRUE);
2892 if (ret != NULL)
2893 {
2894 if (htp != NULL)
2895 *htp = ht;
2896 return ret;
2897 }
2898 }
2899 vim_free(auto_name);
2900 }
2901 }
2902
2877 return NULL; 2903 return NULL;
2878 } 2904 }
2879 2905
2880 /* 2906 /*
2881 * Like find_var() but if the name starts with <SNR>99_ then look in the 2907 * Like find_var() but if the name starts with <SNR>99_ then look in the
3316 { 3342 {
3317 set_var_const(name, 0, NULL, tv, copy, ASSIGN_DECL, 0); 3343 set_var_const(name, 0, NULL, tv, copy, ASSIGN_DECL, 0);
3318 } 3344 }
3319 3345
3320 /* 3346 /*
3321 * Set variable "name" to value in "tv". 3347 * Set variable "name" to value in "tv_arg".
3322 * When "sid" is non-zero "name" is in the script with this ID. 3348 * When "sid" is non-zero "name" is in the script with this ID.
3323 * If the variable already exists and "is_const" is FALSE the value is updated. 3349 * If the variable already exists and "is_const" is FALSE the value is updated.
3324 * Otherwise the variable is created. 3350 * Otherwise the variable is created.
3325 */ 3351 */
3326 void 3352 void