mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Problem: Vim9: cannot set 'number' to a boolean value. Solution: Use tv_get_bool(). (closes #7615)
This commit is contained in:
@@ -1370,8 +1370,14 @@ ex_let_one(
|
||||
|| opt_type == gov_hidden_bool
|
||||
|| opt_type == gov_hidden_number)
|
||||
&& (tv->v_type != VAR_STRING || !in_vim9script()))
|
||||
// number, possibly hidden
|
||||
n = (long)tv_get_number(tv);
|
||||
{
|
||||
if (opt_type == gov_bool || opt_type == gov_hidden_bool)
|
||||
// bool, possibly hidden
|
||||
n = (long)tv_get_bool(tv);
|
||||
else
|
||||
// number, possibly hidden
|
||||
n = (long)tv_get_number(tv);
|
||||
}
|
||||
|
||||
// Avoid setting a string option to the text "v:false" or similar.
|
||||
// In Vim9 script also don't convert a number to string.
|
||||
|
@@ -161,6 +161,15 @@ def Test_assignment()
|
||||
assert_equal(6, &g:ts)
|
||||
&g:ts += 2
|
||||
assert_equal(8, &g:ts)
|
||||
|
||||
&number = true
|
||||
assert_equal(true, &number)
|
||||
&number = 0
|
||||
assert_equal(false, &number)
|
||||
&number = 1
|
||||
assert_equal(true, &number)
|
||||
&number = false
|
||||
assert_equal(false, &number)
|
||||
END
|
||||
CheckDefAndScriptSuccess(lines)
|
||||
|
||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2297,
|
||||
/**/
|
||||
2296,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user