Skip to content

Commit e2a8f07

Browse files
committed
patch 8.2.0103: using null object with execute() has strange effects
Problem: Using null object with execute() has strange effects. Solution: Give an error message ofr Job and Channel.
1 parent da292b0 commit e2a8f07

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/eval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5667,7 +5667,7 @@ tv_get_string_buf_chk(typval_T *varp, char_u *buf)
56675667
#endif
56685668
break;
56695669
case VAR_UNKNOWN:
5670-
emsg(_("E908: using an invalid value as a String"));
5670+
emsg(_(e_inval_string));
56715671
break;
56725672
}
56735673
return NULL;

src/evalfunc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,12 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off)
20152015
return;
20162016
++list->lv_refcount;
20172017
}
2018+
else if (argvars[arg_off].v_type == VAR_JOB
2019+
|| argvars[arg_off].v_type == VAR_CHANNEL)
2020+
{
2021+
emsg(_(e_inval_string));
2022+
return;
2023+
}
20182024
else
20192025
{
20202026
cmd = tv_get_string_chk(&argvars[arg_off]);

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ EXTERN char e_listreq[] INIT(= N_("E714: List required"));
15991599
EXTERN char e_listblobreq[] INIT(= N_("E897: List or Blob required"));
16001600
EXTERN char e_listdictarg[] INIT(= N_("E712: Argument of %s must be a List or Dictionary"));
16011601
EXTERN char e_listdictblobarg[] INIT(= N_("E896: Argument of %s must be a List, Dictionary or Blob"));
1602+
EXTERN char e_inval_string[] INIT(= N_("E908: using an invalid value as a String"));
16021603
#endif
16031604
#ifdef FEAT_QUICKFIX
16041605
EXTERN char e_readerrf[] INIT(= N_("E47: Error while reading errorfile"));

src/testdir/test_execute_func.vim

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ func Test_execute_string()
3838
call assert_equal("\nsomething", execute('echo "something"', 'silent!'))
3939
call assert_equal("", execute('burp', 'silent!'))
4040
call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:')
41-
42-
call assert_equal("", execute(test_null_string()))
4341
endfunc
4442

4543
func Test_execute_list()
@@ -50,7 +48,6 @@ func Test_execute_list()
5048
call assert_equal("\n0\n1\n2\n3", execute(l))
5149

5250
call assert_equal("", execute([]))
53-
call assert_equal("", execute(test_null_list()))
5451
endfunc
5552

5653
func Test_execute_does_not_change_col()
@@ -132,3 +129,15 @@ func Test_win_execute_other_tab()
132129
tabclose
133130
unlet xyz
134131
endfunc
132+
133+
func Test_execute_null()
134+
call assert_equal("", execute(test_null_string()))
135+
call assert_equal("", execute(test_null_list()))
136+
call assert_fails('call execute(test_null_dict())', 'E731:')
137+
call assert_fails('call execute(test_null_blob())', 'E976:')
138+
call assert_fails('call execute(test_null_partial())','E729:')
139+
if has('job')
140+
call assert_fails('call execute(test_null_job())', 'E908:')
141+
call assert_fails('call execute(test_null_channel())', 'E908:')
142+
endif
143+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
103,
745747
/**/
746748
102,
747749
/**/

0 commit comments

Comments
 (0)