forked from aniani/vim
patch 9.0.1266: error for space before ": type" is inconsistent
Problem: Error for space before ": type" is inconsistent. Solution: Give E1059 in more places. (closes #11868)
This commit is contained in:
parent
b8bebd0cd7
commit
ce93d162da
@ -1093,7 +1093,7 @@ get_lval(
|
|||||||
--p;
|
--p;
|
||||||
lp->ll_name_end = p;
|
lp->ll_name_end = p;
|
||||||
}
|
}
|
||||||
if (*p == ':')
|
if (*skipwhite(p) == ':')
|
||||||
{
|
{
|
||||||
char_u *tp = skipwhite(p + 1);
|
char_u *tp = skipwhite(p + 1);
|
||||||
|
|
||||||
@ -1102,6 +1102,11 @@ get_lval(
|
|||||||
semsg(_(e_cannot_use_type_with_this_variable_str), name);
|
semsg(_(e_cannot_use_type_with_this_variable_str), name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (VIM_ISWHITE(*p))
|
||||||
|
{
|
||||||
|
semsg(_(e_no_white_space_allowed_before_colon_str), p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (tp == p + 1 && !quiet)
|
if (tp == p + 1 && !quiet)
|
||||||
{
|
{
|
||||||
semsg(_(e_white_space_required_after_str_str), ":", p);
|
semsg(_(e_white_space_required_after_str_str), ":", p);
|
||||||
|
@ -1363,8 +1363,8 @@ skip_var_one(char_u *arg, int include_type)
|
|||||||
|
|
||||||
if (include_type && vim9)
|
if (include_type && vim9)
|
||||||
{
|
{
|
||||||
if (*end == ':')
|
if (*skipwhite(end) == ':')
|
||||||
end = skip_type(skipwhite(end + 1), FALSE);
|
end = skip_type(skipwhite(skipwhite(end) + 1), FALSE);
|
||||||
}
|
}
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
@ -360,6 +360,13 @@ def Test_null_values()
|
|||||||
v9.CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_type_with_extra_white()
|
||||||
|
var lines =<< trim END
|
||||||
|
const x : number = 3
|
||||||
|
END
|
||||||
|
v9.CheckDefExecAndScriptFailure(lines, 'E1059')
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_keep_type_after_assigning_null()
|
def Test_keep_type_after_assigning_null()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
var b: blob
|
var b: blob
|
||||||
|
@ -695,6 +695,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 */
|
||||||
|
/**/
|
||||||
|
1266,
|
||||||
/**/
|
/**/
|
||||||
1265,
|
1265,
|
||||||
/**/
|
/**/
|
||||||
|
@ -1001,8 +1001,13 @@ compile_for(char_u *arg_start, cctx_T *cctx)
|
|||||||
name = vim_strnsave(arg, varlen);
|
name = vim_strnsave(arg, varlen);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
goto failed;
|
goto failed;
|
||||||
if (*p == ':')
|
if (*skipwhite(p) == ':')
|
||||||
{
|
{
|
||||||
|
if (VIM_ISWHITE(*p))
|
||||||
|
{
|
||||||
|
semsg(_(e_no_white_space_allowed_before_colon_str), p);
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
p = skipwhite(p + 1);
|
p = skipwhite(p + 1);
|
||||||
lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
|
lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
|
||||||
}
|
}
|
||||||
|
@ -1741,11 +1741,16 @@ compile_lhs(
|
|||||||
|
|
||||||
if (lhs->lhs_dest != dest_option && lhs->lhs_dest != dest_func_option)
|
if (lhs->lhs_dest != dest_option && lhs->lhs_dest != dest_func_option)
|
||||||
{
|
{
|
||||||
if (is_decl && *var_end == ':')
|
if (is_decl && *skipwhite(var_end) == ':')
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
// parse optional type: "let var: type = expr"
|
// parse optional type: "let var: type = expr"
|
||||||
|
if (VIM_ISWHITE(*var_end))
|
||||||
|
{
|
||||||
|
semsg(_(e_no_white_space_allowed_before_colon_str), var_end);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
if (!VIM_ISWHITE(var_end[1]))
|
if (!VIM_ISWHITE(var_end[1]))
|
||||||
{
|
{
|
||||||
semsg(_(e_white_space_required_after_str_str), ":", var_end);
|
semsg(_(e_white_space_required_after_str_str), ":", var_end);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user