mirror of
https://github.com/vim/vim.git
synced 2025-11-16 23:24:03 -05:00
patch 9.1.1617: Vim9: some error messages can be improved
Problem: Vim9: some error messages can be improved
Solution: Improve error messages when parsing generic function type
arguments (Yegappan Lakshmanan).
closes: #17957
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
57eb1d496b
commit
1434ea03b1
@@ -149,6 +149,14 @@ generic_func_find_close_bracket(char_u *start)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (VIM_ISWHITE(*(p + 1)) && *skipwhite(p + 1) == '(')
|
||||
{
|
||||
// white space not allowed between '>' and '('
|
||||
semsg(_(e_no_white_space_allowed_after_str_str), ">", start);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (type_count == 0)
|
||||
{
|
||||
semsg(_(e_empty_type_list_for_generic_function_str), start);
|
||||
@@ -326,28 +334,35 @@ parse_generic_func_type_args(
|
||||
|
||||
p = skipwhite(p);
|
||||
|
||||
if (*p == NUL || *p == '>')
|
||||
break;
|
||||
|
||||
// after a type, expect ',' or '>'
|
||||
if (*p != ',' && *p != '>')
|
||||
if (*p != ',')
|
||||
{
|
||||
semsg(_(e_missing_comma_in_generic_function_str), start);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// if there's a comma, require whitespace after it and skip it
|
||||
if (*p == ',')
|
||||
if (*(p + 1) == NUL)
|
||||
break;
|
||||
|
||||
// Require whitespace after a comma and skip it
|
||||
if (!VIM_ISWHITE(*(p + 1)))
|
||||
{
|
||||
if (!VIM_ISWHITE(*(p + 1)))
|
||||
{
|
||||
semsg(_(e_white_space_required_after_str_str), ",", p);
|
||||
return NULL;
|
||||
}
|
||||
p++;
|
||||
semsg(_(e_white_space_required_after_str_str), ",", p);
|
||||
return NULL;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
// ensure the list of types ends in a closing '>'
|
||||
if (*p != '>')
|
||||
{
|
||||
semsg(_(e_missing_closing_angle_bracket_in_generic_function_str),
|
||||
func_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// no whitespace allowed before '>'
|
||||
if (VIM_ISWHITE(*(p - 1)))
|
||||
|
||||
Reference in New Issue
Block a user