mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.4384: Vim9: error message not tested, some code not tested
Problem: Vim9: error message not tested, some code not tested. Solution: Add a couple of test cases. Give an error for a command modifier without a command.
This commit is contained in:
@@ -2791,7 +2791,8 @@ EXTERN char e_missing_argument_type_for_str[]
|
|||||||
// E1080 unused
|
// E1080 unused
|
||||||
EXTERN char e_cannot_unlet_str[]
|
EXTERN char e_cannot_unlet_str[]
|
||||||
INIT(= N_("E1081: Cannot unlet %s"));
|
INIT(= N_("E1081: Cannot unlet %s"));
|
||||||
// E1082 unused
|
EXTERN char e_command_modifier_without_command[]
|
||||||
|
INIT(= N_("E1082: Command modifier without command"));
|
||||||
EXTERN char e_missing_backtick[]
|
EXTERN char e_missing_backtick[]
|
||||||
INIT(= N_("E1083: Missing backtick"));
|
INIT(= N_("E1083: Missing backtick"));
|
||||||
EXTERN char e_cannot_delete_vim9_script_function_str[]
|
EXTERN char e_cannot_delete_vim9_script_function_str[]
|
||||||
|
@@ -2784,6 +2784,7 @@ parse_command_modifiers(
|
|||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int starts_with_colon = FALSE;
|
int starts_with_colon = FALSE;
|
||||||
|
int vim9script = in_vim9script();
|
||||||
|
|
||||||
CLEAR_POINTER(cmod);
|
CLEAR_POINTER(cmod);
|
||||||
cmod->cmod_flags = sticky_cmdmod_flags;
|
cmod->cmod_flags = sticky_cmdmod_flags;
|
||||||
@@ -2819,12 +2820,18 @@ parse_command_modifiers(
|
|||||||
if (eap->nextcmd != NULL)
|
if (eap->nextcmd != NULL)
|
||||||
++eap->nextcmd;
|
++eap->nextcmd;
|
||||||
}
|
}
|
||||||
|
if (vim9script && has_cmdmod(cmod, FALSE))
|
||||||
|
*errormsg = _(e_command_modifier_without_command);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (*eap->cmd == NUL)
|
if (*eap->cmd == NUL)
|
||||||
{
|
{
|
||||||
if (!skip_only)
|
if (!skip_only)
|
||||||
|
{
|
||||||
ex_pressedreturn = TRUE;
|
ex_pressedreturn = TRUE;
|
||||||
|
if (vim9script && has_cmdmod(cmod, FALSE))
|
||||||
|
*errormsg = _(e_command_modifier_without_command);
|
||||||
|
}
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2838,7 +2845,7 @@ parse_command_modifiers(
|
|||||||
// verbose[expr] = 2
|
// verbose[expr] = 2
|
||||||
// But not:
|
// But not:
|
||||||
// verbose [a, b] = list
|
// verbose [a, b] = list
|
||||||
if (in_vim9script())
|
if (vim9script)
|
||||||
{
|
{
|
||||||
char_u *s, *n;
|
char_u *s, *n;
|
||||||
|
|
||||||
@@ -2915,7 +2922,7 @@ parse_command_modifiers(
|
|||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
// in ":filter #pat# cmd" # does not
|
// in ":filter #pat# cmd" # does not
|
||||||
// start a comment
|
// start a comment
|
||||||
&& (!in_vim9script() || VIM_ISWHITE(p[1]))
|
&& (!vim9script || VIM_ISWHITE(p[1]))
|
||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
break;
|
break;
|
||||||
@@ -2928,7 +2935,7 @@ parse_command_modifiers(
|
|||||||
}
|
}
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
// Avoid that "filter(arg)" is recognized.
|
// Avoid that "filter(arg)" is recognized.
|
||||||
if (in_vim9script() && !VIM_ISWHITE(p[-1]))
|
if (vim9script && !VIM_ISWHITE(p[-1]))
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
if (skip_only)
|
if (skip_only)
|
||||||
|
@@ -350,6 +350,11 @@ def Test_assign_unpack()
|
|||||||
assert_equal(1, v1)
|
assert_equal(1, v1)
|
||||||
assert_equal(2, v2)
|
assert_equal(2, v2)
|
||||||
|
|
||||||
|
var _x: number
|
||||||
|
[_x, v2] = [6, 7]
|
||||||
|
assert_equal(6, _x)
|
||||||
|
assert_equal(7, v2)
|
||||||
|
|
||||||
var reslist = []
|
var reslist = []
|
||||||
for text in ['aaa {bbb} ccc', 'ddd {eee} fff']
|
for text in ['aaa {bbb} ccc', 'ddd {eee} fff']
|
||||||
var before: string
|
var before: string
|
||||||
@@ -1481,6 +1486,7 @@ def Test_assign_dict()
|
|||||||
|
|
||||||
v9.CheckDefFailure(["var d: dict<number> = {a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1)
|
v9.CheckDefFailure(["var d: dict<number> = {a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1)
|
||||||
v9.CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)
|
v9.CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)
|
||||||
|
v9.CheckDefFailure(["var d = {x: 1}", "d[1 : 2] = {y: 2}"], 'E1165: Cannot use a range with an assignment: d[1 : 2] =', 2)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_assign_dict_unknown_type()
|
def Test_assign_dict_unknown_type()
|
||||||
|
@@ -1133,6 +1133,16 @@ def Test_useless_command_modifier()
|
|||||||
silent endtry
|
silent endtry
|
||||||
END
|
END
|
||||||
v9.CheckDefAndScriptFailure(lines, 'E1176:', 3)
|
v9.CheckDefAndScriptFailure(lines, 'E1176:', 3)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
leftabove
|
||||||
|
END
|
||||||
|
v9.CheckDefAndScriptFailure(lines, 'E1082:', 1)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
leftabove # comment
|
||||||
|
END
|
||||||
|
v9.CheckDefAndScriptFailure(lines, 'E1082:', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_eval_command()
|
def Test_eval_command()
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
4384,
|
||||||
/**/
|
/**/
|
||||||
4383,
|
4383,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2761,13 +2761,7 @@ compile_def_function(
|
|||||||
cctx.ctx_has_cmdmod = FALSE;
|
cctx.ctx_has_cmdmod = FALSE;
|
||||||
if (parse_command_modifiers(&ea, &errormsg, &local_cmdmod, FALSE)
|
if (parse_command_modifiers(&ea, &errormsg, &local_cmdmod, FALSE)
|
||||||
== FAIL)
|
== FAIL)
|
||||||
{
|
|
||||||
if (errormsg != NULL)
|
|
||||||
goto erret;
|
goto erret;
|
||||||
// empty line or comment
|
|
||||||
line = (char_u *)"";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
generate_cmdmods(&cctx, &local_cmdmod);
|
generate_cmdmods(&cctx, &local_cmdmod);
|
||||||
undo_cmdmod(&local_cmdmod);
|
undo_cmdmod(&local_cmdmod);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user