comparison src/eval.c @ 27669:5c4ab8d4472c v8.2.4360

patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies Commit: https://github.com/vim/vim/commit/a749a42ed25534c88c636e5ab6603f1f97b857a4 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 12 19:52:25 2022 +0000 patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies Problem: Vim9: allowing use of "s:" leads to inconsistencies. Solution: Disallow using "s:" in Vim9 script at the script level.
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Feb 2022 21:00:03 +0100
parents 1712b102d642
children f60d0d823897
comparison
equal deleted inserted replaced
27668:407a08328369 27669:5c4ab8d4472c
874 // When skipping or compiling just find the end of the name. 874 // When skipping or compiling just find the end of the name.
875 lp->ll_name = name; 875 lp->ll_name = name;
876 lp->ll_name_end = find_name_end(name, NULL, NULL, 876 lp->ll_name_end = find_name_end(name, NULL, NULL,
877 FNE_INCL_BR | fne_flags); 877 FNE_INCL_BR | fne_flags);
878 return lp->ll_name_end; 878 return lp->ll_name_end;
879 }
880
881 // Cannot use "s:var" at the Vim9 script level. "s: type" is OK.
882 if (in_vim9script() && at_script_level()
883 && name[0] == 's' && name[1] == ':' && !VIM_ISWHITE(name[2]))
884 {
885 semsg(_(e_cannot_use_s_colon_in_vim9_script_str), name);
886 return NULL;
879 } 887 }
880 888
881 // Find the end of the name. 889 // Find the end of the name.
882 p = find_name_end(name, &expr_start, &expr_end, fne_flags); 890 p = find_name_end(name, &expr_start, &expr_end, fne_flags);
883 lp->ll_name_end = p; 891 lp->ll_name_end = p;
3730 if (evaluate && in_vim9script() && len == 1 && *s == '_') 3738 if (evaluate && in_vim9script() && len == 1 && *s == '_')
3731 { 3739 {
3732 emsg(_(e_cannot_use_underscore_here)); 3740 emsg(_(e_cannot_use_underscore_here));
3733 ret = FAIL; 3741 ret = FAIL;
3734 } 3742 }
3743 else if (evaluate && in_vim9script() && len > 2
3744 && s[0] == 's' && s[1] == ':')
3745 {
3746 semsg(_(e_cannot_use_s_colon_in_vim9_script_str), s);
3747 ret = FAIL;
3748 }
3735 else if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(') 3749 else if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(')
3736 { 3750 {
3737 // "name(..." recursive! 3751 // "name(..." recursive!
3738 *arg = skipwhite(*arg); 3752 *arg = skipwhite(*arg);
3739 ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL); 3753 ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);