vim-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.

e2a8f0773e

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq 2023-04-15 13:10:36 +08:00
parent d372eedcfa
commit 4c276bbd18
3 changed files with 15 additions and 4 deletions

View File

@ -3806,7 +3806,7 @@ static const char *const str_errors[] = {
[VAR_DICT]= N_("E731: using Dictionary as a String"),
[VAR_FLOAT]= e_float_as_string,
[VAR_BLOB]= N_("E976: using Blob as a String"),
[VAR_UNKNOWN]= N_("E908: using an invalid value as a String"),
[VAR_UNKNOWN]= e_inval_string,
};
#undef FUNC_ERROR

View File

@ -998,6 +998,7 @@ EXTERN const char e_listarg[] INIT(= N_("E686: Argument of %s must be a List"));
EXTERN const char e_unsupportedoption[] INIT(= N_("E519: Option not supported"));
EXTERN const char e_fnametoolong[] INIT(= N_("E856: Filename too long"));
EXTERN const char e_float_as_string[] INIT(= N_("E806: using Float as a String"));
EXTERN const char e_inval_string[] INIT(= N_("E908: using an invalid value as a String"));
EXTERN const char e_cannot_edit_other_buf[] INIT(= N_("E788: Not allowed to edit another buffer now"));
EXTERN const char e_cmdmap_err[] INIT(= N_("E5520: <Cmd> mapping must end with <CR>"));

View File

@ -41,8 +41,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(""))
endfunc
func Test_execute_list()
@ -53,7 +51,6 @@ func Test_execute_list()
call assert_equal("\n0\n1\n2\n3", execute(l))
call assert_equal("", execute([]))
call assert_equal("", execute(v:_null_list))
endfunc
func Test_execute_does_not_change_col()
@ -173,4 +170,17 @@ func Test_win_execute_visual_redraw()
bwipe!
endfunc
func Test_execute_null()
call assert_equal("", execute(v:_null_string))
call assert_equal("", execute(v:_null_list))
call assert_fails('call execute(v:_null_dict)', 'E731:')
call assert_fails('call execute(v:_null_blob)', 'E976:')
" Nvim doesn't have null partials
" 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
" vim: shiftwidth=2 sts=2 expandtab