comparison src/ex_docmd.c @ 27716:4097434c7c67 v8.2.4384

patch 8.2.4384: Vim9: error message not tested, some code not tested Commit: https://github.com/vim/vim/commit/bc510064027da8024d59460c9c816aea4ffac096 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 14 21:19:04 2022 +0000 patch 8.2.4384: Vim9: error message not tested, some code not tested Problem: Vim9: error message not tested, some code not tested. Solution: Add a couple of test cases. Give an error for a command modifier without a command.
author Bram Moolenaar <Bram@vim.org>
date Mon, 14 Feb 2022 22:30:03 +0100
parents 1712b102d642
children 2631b9021808
comparison
equal deleted inserted replaced
27715:4cbf7a833468 27716:4097434c7c67
2782 cmdmod_T *cmod, 2782 cmdmod_T *cmod,
2783 int skip_only) 2783 int skip_only)
2784 { 2784 {
2785 char_u *p; 2785 char_u *p;
2786 int starts_with_colon = FALSE; 2786 int starts_with_colon = FALSE;
2787 int vim9script = in_vim9script();
2787 2788
2788 CLEAR_POINTER(cmod); 2789 CLEAR_POINTER(cmod);
2789 cmod->cmod_flags = sticky_cmdmod_flags; 2790 cmod->cmod_flags = sticky_cmdmod_flags;
2790 2791
2791 // Repeat until no more command modifiers are found. 2792 // Repeat until no more command modifiers are found.
2817 { 2818 {
2818 eap->nextcmd = vim_strchr(eap->cmd, '\n'); 2819 eap->nextcmd = vim_strchr(eap->cmd, '\n');
2819 if (eap->nextcmd != NULL) 2820 if (eap->nextcmd != NULL)
2820 ++eap->nextcmd; 2821 ++eap->nextcmd;
2821 } 2822 }
2823 if (vim9script && has_cmdmod(cmod, FALSE))
2824 *errormsg = _(e_command_modifier_without_command);
2822 return FAIL; 2825 return FAIL;
2823 } 2826 }
2824 if (*eap->cmd == NUL) 2827 if (*eap->cmd == NUL)
2825 { 2828 {
2826 if (!skip_only) 2829 if (!skip_only)
2830 {
2827 ex_pressedreturn = TRUE; 2831 ex_pressedreturn = TRUE;
2832 if (vim9script && has_cmdmod(cmod, FALSE))
2833 *errormsg = _(e_command_modifier_without_command);
2834 }
2828 return FAIL; 2835 return FAIL;
2829 } 2836 }
2830 2837
2831 p = skip_range(eap->cmd, TRUE, NULL); 2838 p = skip_range(eap->cmd, TRUE, NULL);
2832 2839
2836 // silent! verbose = func() 2843 // silent! verbose = func()
2837 // verbose.member = 2 2844 // verbose.member = 2
2838 // verbose[expr] = 2 2845 // verbose[expr] = 2
2839 // But not: 2846 // But not:
2840 // verbose [a, b] = list 2847 // verbose [a, b] = list
2841 if (in_vim9script()) 2848 if (vim9script)
2842 { 2849 {
2843 char_u *s, *n; 2850 char_u *s, *n;
2844 2851
2845 for (s = p; ASCII_ISALPHA(*s); ++s) 2852 for (s = p; ASCII_ISALPHA(*s); ++s)
2846 ; 2853 ;
2913 || *p == NUL 2920 || *p == NUL
2914 || (ends_excmd(*p) 2921 || (ends_excmd(*p)
2915 #ifdef FEAT_EVAL 2922 #ifdef FEAT_EVAL
2916 // in ":filter #pat# cmd" # does not 2923 // in ":filter #pat# cmd" # does not
2917 // start a comment 2924 // start a comment
2918 && (!in_vim9script() || VIM_ISWHITE(p[1])) 2925 && (!vim9script || VIM_ISWHITE(p[1]))
2919 #endif 2926 #endif
2920 )) 2927 ))
2921 break; 2928 break;
2922 if (*p == '!') 2929 if (*p == '!')
2923 { 2930 {
2926 if (*p == NUL || ends_excmd(*p)) 2933 if (*p == NUL || ends_excmd(*p))
2927 break; 2934 break;
2928 } 2935 }
2929 #ifdef FEAT_EVAL 2936 #ifdef FEAT_EVAL
2930 // Avoid that "filter(arg)" is recognized. 2937 // Avoid that "filter(arg)" is recognized.
2931 if (in_vim9script() && !VIM_ISWHITE(p[-1])) 2938 if (vim9script && !VIM_ISWHITE(p[-1]))
2932 break; 2939 break;
2933 #endif 2940 #endif
2934 if (skip_only) 2941 if (skip_only)
2935 p = skip_vimgrep_pat(p, NULL, NULL); 2942 p = skip_vimgrep_pat(p, NULL, NULL);
2936 else 2943 else