mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Problem: Vim9: runtime and compile time type checks are not the same. Solution: Add more runtime type checks for builtin functions. (Yegappan Lakshmanan, closes #8646)
This commit is contained in:
committed by
Bram Moolenaar
parent
5d7c2df536
commit
4490ec4e83
@@ -5284,11 +5284,6 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
|
||||
FILE *fd2 = NULL;
|
||||
char_u *textline = NULL;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_dict_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
// First open the files. If this fails bail out.
|
||||
fname1 = tv_get_string_buf_chk(&argvars[0], buf1);
|
||||
if (do_diff)
|
||||
@@ -5666,6 +5661,11 @@ f_term_dumpdiff(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_dumpload(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
if (in_vim9script()
|
||||
&& (check_for_string_arg(argvars, 0) == FAIL
|
||||
|| check_for_dict_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
term_load_dump(argvars, rettv, FALSE);
|
||||
}
|
||||
|
||||
@@ -5675,8 +5675,12 @@ f_term_dumpload(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_getaltscreen(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_getaltscreen()");
|
||||
buf_T *buf;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_getaltscreen()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
rettv->vval.v_number = buf->b_term->tl_using_altscreen;
|
||||
@@ -5729,13 +5733,18 @@ f_term_getattr(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_getcursor(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_getcursor()");
|
||||
buf_T *buf;
|
||||
term_T *term;
|
||||
list_T *l;
|
||||
dict_T *d;
|
||||
|
||||
if (rettv_list_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_getcursor()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
term = buf->b_term;
|
||||
@@ -5762,8 +5771,12 @@ f_term_getcursor(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_getjob(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_getjob()");
|
||||
buf_T *buf;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_getjob()");
|
||||
if (buf == NULL)
|
||||
{
|
||||
rettv->v_type = VAR_SPECIAL;
|
||||
@@ -5847,8 +5860,12 @@ f_term_getline(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_getscrolled(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_getscrolled()");
|
||||
buf_T *buf;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_getscrolled()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
rettv->vval.v_number = buf->b_term->tl_scrollback_scrolled;
|
||||
@@ -5860,11 +5877,16 @@ f_term_getscrolled(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_getsize(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_getsize()");
|
||||
buf_T *buf;
|
||||
list_T *l;
|
||||
|
||||
if (rettv_list_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_getsize()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
|
||||
@@ -5916,11 +5938,16 @@ f_term_setsize(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
void
|
||||
f_term_getstatus(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_getstatus()");
|
||||
buf_T *buf;
|
||||
term_T *term;
|
||||
char_u val[100];
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_getstatus()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
term = buf->b_term;
|
||||
@@ -5940,9 +5967,14 @@ f_term_getstatus(typval_T *argvars, typval_T *rettv)
|
||||
void
|
||||
f_term_gettitle(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_gettitle()");
|
||||
buf_T *buf;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_gettitle()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
|
||||
@@ -6179,7 +6211,7 @@ f_term_sendkeys(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
void
|
||||
f_term_getansicolors(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
buf_T *buf = term_get_buf(argvars, "term_getansicolors()");
|
||||
buf_T *buf;
|
||||
term_T *term;
|
||||
VTermState *state;
|
||||
VTermColor color;
|
||||
@@ -6190,6 +6222,10 @@ f_term_getansicolors(typval_T *argvars, typval_T *rettv)
|
||||
if (rettv_list_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_getansicolors()");
|
||||
if (buf == NULL)
|
||||
return;
|
||||
term = buf->b_term;
|
||||
@@ -6218,9 +6254,8 @@ f_term_setansicolors(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
term_T *term;
|
||||
|
||||
if (in_vim9script()
|
||||
&& (check_for_opt_buffer_arg(argvars, 0) == FAIL
|
||||
|| (argvars[0].v_type != VAR_UNKNOWN
|
||||
&& check_for_opt_list_arg(argvars, 1) == FAIL)))
|
||||
&& (check_for_buffer_arg(argvars, 0) == FAIL
|
||||
|| check_for_list_arg(argvars, 1) == FAIL))
|
||||
return;
|
||||
|
||||
buf = term_get_buf(argvars, "term_setansicolors()");
|
||||
|
Reference in New Issue
Block a user