mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 9.0.0090: no error when assigning bool to a string option
Problem: No error when assigning bool to a string option with setwinvar(). Solution: Give an error (closes #10766)
This commit is contained in:
@@ -4223,6 +4223,11 @@ set_option_from_tv(char_u *varname, typval_T *varp)
|
|||||||
|
|
||||||
if (varp->v_type == VAR_BOOL)
|
if (varp->v_type == VAR_BOOL)
|
||||||
{
|
{
|
||||||
|
if (is_string_option(varname))
|
||||||
|
{
|
||||||
|
emsg(_(e_string_required));
|
||||||
|
return;
|
||||||
|
}
|
||||||
numval = (long)varp->vval.v_number;
|
numval = (long)varp->vval.v_number;
|
||||||
strval = (char_u *)"0"; // avoid using "false"
|
strval = (char_u *)"0"; // avoid using "false"
|
||||||
}
|
}
|
||||||
|
14
src/option.c
14
src/option.c
@@ -4478,6 +4478,20 @@ is_option_allocated(char *name)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* Return TRUE if "name" is a string option.
|
||||||
|
* Returns FALSE if option "name" does not exist.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
is_string_option(char_u *name)
|
||||||
|
{
|
||||||
|
int idx = findoption(name);
|
||||||
|
|
||||||
|
return idx >= 0 && (options[idx].flags & P_STRING);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
|
* Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
|
||||||
* When "has_lt" is true there is a '<' before "*arg_arg".
|
* When "has_lt" is true there is a '<' before "*arg_arg".
|
||||||
|
@@ -43,6 +43,7 @@ char_u *get_term_code(char_u *tname);
|
|||||||
char_u *get_highlight_default(void);
|
char_u *get_highlight_default(void);
|
||||||
char_u *get_encoding_default(void);
|
char_u *get_encoding_default(void);
|
||||||
int is_option_allocated(char *name);
|
int is_option_allocated(char *name);
|
||||||
|
int is_string_option(char_u *name);
|
||||||
int makeset(FILE *fd, int opt_flags, int local_only);
|
int makeset(FILE *fd, int opt_flags, int local_only);
|
||||||
int makefoldset(FILE *fd);
|
int makefoldset(FILE *fd);
|
||||||
void clear_termoptions(void);
|
void clear_termoptions(void);
|
||||||
|
@@ -3719,6 +3719,7 @@ def Test_setwinvar()
|
|||||||
v9.CheckDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
|
v9.CheckDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
|
||||||
v9.CheckDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
|
v9.CheckDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
|
||||||
assert_fails('setwinvar(1, "", 10)', 'E461: Illegal variable name')
|
assert_fails('setwinvar(1, "", 10)', 'E461: Illegal variable name')
|
||||||
|
assert_fails('setwinvar(0, "&rulerformat", true)', 'E928:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_sha256()
|
def Test_sha256()
|
||||||
|
@@ -735,6 +735,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 */
|
||||||
|
/**/
|
||||||
|
90,
|
||||||
/**/
|
/**/
|
||||||
89,
|
89,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user