]> granicus.if.org Git - vim/commitdiff
patch 8.2.0103: using null object with execute() has strange effects v8.2.0103
authorBram Moolenaar <Bram@vim.org>
Wed, 8 Jan 2020 18:32:18 +0000 (19:32 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 8 Jan 2020 18:32:18 +0000 (19:32 +0100)
Problem:    Using null object with execute() has strange effects.
Solution:   Give an error message ofr Job and Channel.

src/eval.c
src/evalfunc.c
src/globals.h
src/testdir/test_execute_func.vim
src/version.c

index 6e88c5c2189cf72f7285b4b2601f3cb3e23f8116..e0f27a0986451c07afbe681431c700a37d2b10a9 100644 (file)
@@ -5667,7 +5667,7 @@ tv_get_string_buf_chk(typval_T *varp, char_u *buf)
 #endif
            break;
        case VAR_UNKNOWN:
-           emsg(_("E908: using an invalid value as a String"));
+           emsg(_(e_inval_string));
            break;
     }
     return NULL;
index af43fb96ec9136f44c26299022a5435b5decdb89..f192506d848cbb0a12a95496a5d55cd8bbaa6ace 100644 (file)
@@ -2015,6 +2015,12 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off)
            return;
        ++list->lv_refcount;
     }
+    else if (argvars[arg_off].v_type == VAR_JOB
+           || argvars[arg_off].v_type == VAR_CHANNEL)
+    {
+       emsg(_(e_inval_string));
+       return;
+    }
     else
     {
        cmd = tv_get_string_chk(&argvars[arg_off]);
index e1738693def8ff9365e328f28009ca0c0e9ff44c..34430d3e0faff36cc3432707f12451bcc84d08fb 100644 (file)
@@ -1599,6 +1599,7 @@ EXTERN char e_listreq[]   INIT(= N_("E714: List required"));
 EXTERN char e_listblobreq[]    INIT(= N_("E897: List or Blob required"));
 EXTERN char e_listdictarg[]    INIT(= N_("E712: Argument of %s must be a List or Dictionary"));
 EXTERN char e_listdictblobarg[]        INIT(= N_("E896: Argument of %s must be a List, Dictionary or Blob"));
+EXTERN char e_inval_string[]   INIT(= N_("E908: using an invalid value as a String"));
 #endif
 #ifdef FEAT_QUICKFIX
 EXTERN char e_readerrf[]       INIT(= N_("E47: Error while reading errorfile"));
index 7934e60846639a579a788eb2f7b00cb4d2403f85..30dcb6202d4fd148cdbb16cb959dbaae9d087af3 100644 (file)
@@ -38,8 +38,6 @@ func Test_execute_string()
   call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
   call assert_equal("", execute('burp', 'silent!'))
   call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:')
-
-  call assert_equal("", execute(test_null_string()))
 endfunc
 
 func Test_execute_list()
@@ -50,7 +48,6 @@ func Test_execute_list()
   call assert_equal("\n0\n1\n2\n3", execute(l))
 
   call assert_equal("", execute([]))
-  call assert_equal("", execute(test_null_list()))
 endfunc
 
 func Test_execute_does_not_change_col()
@@ -132,3 +129,15 @@ func Test_win_execute_other_tab()
   tabclose
   unlet xyz
 endfunc
+
+func Test_execute_null()
+  call assert_equal("", execute(test_null_string()))
+  call assert_equal("", execute(test_null_list()))
+  call assert_fails('call execute(test_null_dict())', 'E731:')
+  call assert_fails('call execute(test_null_blob())', 'E976:')
+  call assert_fails('call execute(test_null_partial())','E729:')
+  if has('job')
+    call assert_fails('call execute(test_null_job())', 'E908:')
+    call assert_fails('call execute(test_null_channel())', 'E908:')
+  endif
+endfunc
index a02b198c5ce4e7cb175b5f93d1a28549d3b656ab..54104ebac2c781b4eb4395c5458167af2f75ad9f 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    103,
 /**/
     102,
 /**/