mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.3299: Vim9: exists() does not handle much at compile time
Problem: Vim9: exists() does not handle much at compile time. Solution: Handle variable names. (closes #8688)
This commit is contained in:
parent
6f6d58c380
commit
5671f3f076
@ -3552,7 +3552,14 @@ f_exists(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
else if (*p == '*') // internal or user defined function
|
else if (*p == '*') // internal or user defined function
|
||||||
{
|
{
|
||||||
|
int save_version = current_sctx.sc_version;
|
||||||
|
|
||||||
|
// Vim9 script assumes a function is script-local, but here we want to
|
||||||
|
// find any matching function.
|
||||||
|
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
|
||||||
|
current_sctx.sc_version = SCRIPT_VERSION_MAX;
|
||||||
n = function_exists(p + 1, FALSE);
|
n = function_exists(p + 1, FALSE);
|
||||||
|
current_sctx.sc_version = save_version;
|
||||||
}
|
}
|
||||||
else if (*p == '?') // internal function only
|
else if (*p == '?') // internal function only
|
||||||
{
|
{
|
||||||
|
@ -787,6 +787,8 @@ def Test_exepath()
|
|||||||
CheckDefExecFailure(['echo exepath("")'], 'E1175:')
|
CheckDefExecFailure(['echo exepath("")'], 'E1175:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
command DoSomeCommand let g:didSomeCommand = 4
|
||||||
|
|
||||||
def Test_exists()
|
def Test_exists()
|
||||||
CheckDefAndScriptFailure2(['exists(10)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
CheckDefAndScriptFailure2(['exists(10)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
|
||||||
call assert_equal(1, exists('&tabstop'))
|
call assert_equal(1, exists('&tabstop'))
|
||||||
@ -809,6 +811,26 @@ def Test_exists()
|
|||||||
else
|
else
|
||||||
assert_report('tabstop option not existing?')
|
assert_report('tabstop option not existing?')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if exists(':DoSomeCommand') >= 2
|
||||||
|
DoSomeCommand
|
||||||
|
endif
|
||||||
|
assert_equal(4, g:didSomeCommand)
|
||||||
|
if exists(':NoSuchCommand') >= 2
|
||||||
|
NoSuchCommand
|
||||||
|
endif
|
||||||
|
|
||||||
|
var found = false
|
||||||
|
if exists('*CheckScriptSuccess')
|
||||||
|
found = true
|
||||||
|
endif
|
||||||
|
assert_true(found)
|
||||||
|
if exists('*NoSuchFunction')
|
||||||
|
NoSuchFunction()
|
||||||
|
endif
|
||||||
|
if exists('*no_such_function')
|
||||||
|
no_such_function()
|
||||||
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_expand()
|
def Test_expand()
|
||||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3299,
|
||||||
/**/
|
/**/
|
||||||
3298,
|
3298,
|
||||||
/**/
|
/**/
|
||||||
|
@ -3417,8 +3417,8 @@ compile_call(
|
|||||||
s = skipwhite(s);
|
s = skipwhite(s);
|
||||||
if (*s == ')' && argvars[0].v_type == VAR_STRING
|
if (*s == ')' && argvars[0].v_type == VAR_STRING
|
||||||
&& ((is_has && !dynamic_feature(argvars[0].vval.v_string))
|
&& ((is_has && !dynamic_feature(argvars[0].vval.v_string))
|
||||||
|| (!is_has && (*argvars[0].vval.v_string == '+'
|
|| (!is_has && vim_strchr((char_u *)"+&:*",
|
||||||
|| *argvars[0].vval.v_string == '&'))))
|
*argvars[0].vval.v_string))))
|
||||||
{
|
{
|
||||||
typval_T *tv = &ppconst->pp_tv[ppconst->pp_used];
|
typval_T *tv = &ppconst->pp_tv[ppconst->pp_used];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user