forked from aniani/vim
patch 8.2.4940: some code is never used
Problem: Some code is never used. Solution: Remove dead code. Add a few more test cases.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
int generate_ppconst(cctx_T *cctx, ppconst_T *ppconst);
|
int generate_ppconst(cctx_T *cctx, ppconst_T *ppconst);
|
||||||
void clear_ppconst(ppconst_T *ppconst);
|
void clear_ppconst(ppconst_T *ppconst);
|
||||||
int compile_member(int is_slice, int *keeping_dict, cctx_T *cctx);
|
int compile_member(int is_slice, int *keeping_dict, cctx_T *cctx);
|
||||||
int compile_load_scriptvar(cctx_T *cctx, char_u *name, char_u *start, char_u **end, int error);
|
int compile_load_scriptvar(cctx_T *cctx, char_u *name, char_u *start, char_u **end);
|
||||||
int compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int is_expr, int error);
|
int compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int is_expr, int error);
|
||||||
char_u *to_name_end(char_u *arg, int use_namespace);
|
char_u *to_name_end(char_u *arg, int use_namespace);
|
||||||
char_u *to_name_const_end(char_u *arg);
|
char_u *to_name_const_end(char_u *arg);
|
||||||
|
@@ -4083,6 +4083,11 @@ def Test_substitute()
|
|||||||
assert_equal("4", substitute("3", '\d', '\=str2nr(submatch(0)) + 1', 'g'))
|
assert_equal("4", substitute("3", '\d', '\=str2nr(submatch(0)) + 1', 'g'))
|
||||||
END
|
END
|
||||||
v9.CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
assert_equal("4", substitute("3", '\d', '\="text" x', 'g'))
|
||||||
|
END
|
||||||
|
v9.CheckDefAndScriptFailure(lines, 'E488: Trailing characters: x')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_swapinfo()
|
def Test_swapinfo()
|
||||||
|
@@ -2695,6 +2695,21 @@ def Test_expr8funcref()
|
|||||||
Test()
|
Test()
|
||||||
END
|
END
|
||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
# using funcref in legacy script
|
||||||
|
lines =<< trim END
|
||||||
|
def s:Refme(): string
|
||||||
|
return 'yes'
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def TestFunc()
|
||||||
|
var TheRef = s:Refme
|
||||||
|
assert_equal('yes', TheRef())
|
||||||
|
enddef
|
||||||
|
|
||||||
|
call TestFunc()
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
let g:test_space_dict = {'': 'empty', ' ': 'space'}
|
let g:test_space_dict = {'': 'empty', ' ': 'space'}
|
||||||
|
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
4940,
|
||||||
/**/
|
/**/
|
||||||
4939,
|
4939,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1140,7 +1140,7 @@ generate_loadvar(
|
|||||||
break;
|
break;
|
||||||
case dest_script:
|
case dest_script:
|
||||||
compile_load_scriptvar(cctx,
|
compile_load_scriptvar(cctx,
|
||||||
name + (name[1] == ':' ? 2 : 0), NULL, NULL, TRUE);
|
name + (name[1] == ':' ? 2 : 0), NULL, NULL);
|
||||||
break;
|
break;
|
||||||
case dest_env:
|
case dest_env:
|
||||||
// Include $ in the name here
|
// Include $ in the name here
|
||||||
|
@@ -140,9 +140,8 @@ compile_member(int is_slice, int *keeping_dict, cctx_T *cctx)
|
|||||||
typep->type_curr = &t_any;
|
typep->type_curr = &t_any;
|
||||||
typep->type_decl = &t_any;
|
typep->type_decl = &t_any;
|
||||||
}
|
}
|
||||||
if (may_generate_2STRING(-1, FALSE, cctx) == FAIL)
|
if (may_generate_2STRING(-1, FALSE, cctx) == FAIL
|
||||||
return FAIL;
|
|| generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL)
|
||||||
if (generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL)
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
if (keeping_dict != NULL)
|
if (keeping_dict != NULL)
|
||||||
*keeping_dict = TRUE;
|
*keeping_dict = TRUE;
|
||||||
@@ -246,8 +245,7 @@ compile_load_scriptvar(
|
|||||||
cctx_T *cctx,
|
cctx_T *cctx,
|
||||||
char_u *name, // variable NUL terminated
|
char_u *name, // variable NUL terminated
|
||||||
char_u *start, // start of variable
|
char_u *start, // start of variable
|
||||||
char_u **end, // end of variable, may be NULL
|
char_u **end) // end of variable, may be NULL
|
||||||
int error) // when TRUE may give error
|
|
||||||
{
|
{
|
||||||
scriptitem_T *si;
|
scriptitem_T *si;
|
||||||
int idx;
|
int idx;
|
||||||
@@ -368,14 +366,10 @@ compile_load_scriptvar(
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx == -1 || si->sn_version != SCRIPT_VERSION_VIM9)
|
// Can only get here if we know "name" is a script variable and not in a
|
||||||
// variable is not in sn_var_vals: old style script.
|
// Vim9 script (variable is not in sn_var_vals): old style script.
|
||||||
return generate_OLDSCRIPT(cctx, ISN_LOADS, name, current_sctx.sc_sid,
|
return generate_OLDSCRIPT(cctx, ISN_LOADS, name, current_sctx.sc_sid,
|
||||||
&t_any);
|
&t_any);
|
||||||
|
|
||||||
if (error)
|
|
||||||
semsg(_(e_item_not_found_str), name);
|
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -462,7 +456,7 @@ compile_load(
|
|||||||
res = generate_funcref(cctx, name, FALSE);
|
res = generate_funcref(cctx, name, FALSE);
|
||||||
else
|
else
|
||||||
res = compile_load_scriptvar(cctx, name,
|
res = compile_load_scriptvar(cctx, name,
|
||||||
NULL, &end, error);
|
NULL, &end);
|
||||||
break;
|
break;
|
||||||
case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
|
case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
|
||||||
{
|
{
|
||||||
@@ -538,7 +532,7 @@ compile_load(
|
|||||||
// already exists in a Vim9 script or when it's imported.
|
// already exists in a Vim9 script or when it's imported.
|
||||||
if (script_var_exists(*arg, len, cctx, NULL) == OK
|
if (script_var_exists(*arg, len, cctx, NULL) == OK
|
||||||
|| find_imported(name, 0, FALSE) != NULL)
|
|| find_imported(name, 0, FALSE) != NULL)
|
||||||
res = compile_load_scriptvar(cctx, name, *arg, &end, FALSE);
|
res = compile_load_scriptvar(cctx, name, *arg, &end);
|
||||||
|
|
||||||
// When evaluating an expression and the name starts with an
|
// When evaluating an expression and the name starts with an
|
||||||
// uppercase letter it can be a user defined function.
|
// uppercase letter it can be a user defined function.
|
||||||
|
Reference in New Issue
Block a user