mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.3296: Vim9: cannot add a number to a float
Problem: Vim9: cannot add a number to a float. Solution: Accept a number if the destination is a float. (closes #8703)
This commit is contained in:
@@ -245,6 +245,23 @@ def Test_assignment()
|
|||||||
END
|
END
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_float_and_number()
|
||||||
|
if !has('float')
|
||||||
|
MissingFeature float
|
||||||
|
else
|
||||||
|
var lines =<< trim END
|
||||||
|
var f: float
|
||||||
|
f += 2
|
||||||
|
f -= 1
|
||||||
|
assert_equal(1.0, f)
|
||||||
|
++f
|
||||||
|
--f
|
||||||
|
assert_equal(1.0, f)
|
||||||
|
END
|
||||||
|
CheckDefAndScriptSuccess(lines)
|
||||||
|
endif
|
||||||
|
enddef
|
||||||
|
|
||||||
let g:someNumber = 43
|
let g:someNumber = 43
|
||||||
|
|
||||||
def Test_assign_concat()
|
def Test_assign_concat()
|
||||||
|
@@ -755,6 +755,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 */
|
||||||
|
/**/
|
||||||
|
3296,
|
||||||
/**/
|
/**/
|
||||||
3295,
|
3295,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -7021,8 +7021,10 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
|||||||
|
|
||||||
// Special case: assigning to @# can use a number or a
|
// Special case: assigning to @# can use a number or a
|
||||||
// string.
|
// string.
|
||||||
if (lhs_type == &t_number_or_string
|
// Also: can assign a number to a float.
|
||||||
&& rhs_type->tt_type == VAR_NUMBER)
|
if ((lhs_type == &t_number_or_string
|
||||||
|
|| lhs_type == &t_float)
|
||||||
|
&& rhs_type->tt_type == VAR_NUMBER)
|
||||||
lhs_type = &t_number;
|
lhs_type = &t_number;
|
||||||
if (*p != '=' && need_type(rhs_type, lhs_type,
|
if (*p != '=' && need_type(rhs_type, lhs_type,
|
||||||
-1, 0, cctx, FALSE, FALSE) == FAIL)
|
-1, 0, cctx, FALSE, FALSE) == FAIL)
|
||||||
|
Reference in New Issue
Block a user