mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 23:38:17 +00:00
vim-patch:7.4.1546
Problem: Sticky type checking is more annoying than useful.
Solution: Remove the error for changing a variable type.
f6f32c38bf
Note: There are a bunch of other changes to eval.txt that I believe are
N/A and not related to this patch.
This commit is contained in:
@@ -103,17 +103,8 @@ to Float, printf() for Float to String and float2nr() for Float to Number.
|
|||||||
*E891* *E892* *E893* *E894*
|
*E891* *E892* *E893* *E894*
|
||||||
When expecting a Float a Number can also be used, but nothing else.
|
When expecting a Float a Number can also be used, but nothing else.
|
||||||
|
|
||||||
*E706* *sticky-type-checking*
|
*no-type-checking*
|
||||||
You will get an error if you try to change the type of a variable. You need
|
You will not get an error if you try to change the type of a variable.
|
||||||
to |:unlet| it first to avoid this error. String and Number are considered
|
|
||||||
equivalent though, as well are Float and Number. Consider this sequence of
|
|
||||||
commands: >
|
|
||||||
:let l = "string"
|
|
||||||
:let l = 44 " changes type from String to Number
|
|
||||||
:let l = [1, 2, 3] " error! l is still a Number
|
|
||||||
:let l = 4.4 " changes type from Number to Float
|
|
||||||
:let l = "string" " error!
|
|
||||||
|
|
||||||
|
|
||||||
1.2 Function references ~
|
1.2 Function references ~
|
||||||
*Funcref* *E695* *E718*
|
*Funcref* *E695* *E718*
|
||||||
|
@@ -18886,19 +18886,6 @@ set_var (
|
|||||||
|| tv_check_lock(v->di_tv.v_lock, name, false)) {
|
|| tv_check_lock(v->di_tv.v_lock, name, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (v->di_tv.v_type != tv->v_type
|
|
||||||
&& !((v->di_tv.v_type == VAR_STRING
|
|
||||||
|| v->di_tv.v_type == VAR_NUMBER)
|
|
||||||
&& (tv->v_type == VAR_STRING
|
|
||||||
|| tv->v_type == VAR_NUMBER))
|
|
||||||
&& !((v->di_tv.v_type == VAR_NUMBER
|
|
||||||
|| v->di_tv.v_type == VAR_FLOAT)
|
|
||||||
&& (tv->v_type == VAR_NUMBER
|
|
||||||
|| tv->v_type == VAR_FLOAT))
|
|
||||||
) {
|
|
||||||
EMSG2(_("E706: Variable type mismatch for: %s"), name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle setting internal v: variables separately where needed to
|
// Handle setting internal v: variables separately where needed to
|
||||||
// prevent changing the type.
|
// prevent changing the type.
|
||||||
@@ -18908,7 +18895,7 @@ set_var (
|
|||||||
if (copy || tv->v_type != VAR_STRING)
|
if (copy || tv->v_type != VAR_STRING)
|
||||||
v->di_tv.vval.v_string = vim_strsave(get_tv_string(tv));
|
v->di_tv.vval.v_string = vim_strsave(get_tv_string(tv));
|
||||||
else {
|
else {
|
||||||
/* Take over the string to avoid an extra alloc/free. */
|
// Take over the string to avoid an extra alloc/free.
|
||||||
v->di_tv.vval.v_string = tv->vval.v_string;
|
v->di_tv.vval.v_string = tv->vval.v_string;
|
||||||
tv->vval.v_string = NULL;
|
tv->vval.v_string = NULL;
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@ SCRIPTS := \
|
|||||||
# Tests using runtest.vim.vim.
|
# Tests using runtest.vim.vim.
|
||||||
# Keep test_alot*.res as the last one, sort the others.
|
# Keep test_alot*.res as the last one, sort the others.
|
||||||
NEW_TESTS = \
|
NEW_TESTS = \
|
||||||
|
test_assign.res \
|
||||||
test_cursor_func.res \
|
test_cursor_func.res \
|
||||||
test_hardcopy.res \
|
test_hardcopy.res \
|
||||||
test_help_tagjump.res \
|
test_help_tagjump.res \
|
||||||
|
9
src/nvim/testdir/test_assign.vim
Normal file
9
src/nvim/testdir/test_assign.vim
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
" Test for assignment
|
||||||
|
|
||||||
|
func Test_no_type_checking()
|
||||||
|
let v = 1
|
||||||
|
let v = [1,2,3]
|
||||||
|
let v = {'a':1, 'b':2}
|
||||||
|
let v = 3.4
|
||||||
|
let v = 'hello'
|
||||||
|
endfunc
|
@@ -153,7 +153,7 @@ static int included_patches[] = {
|
|||||||
// 1549,
|
// 1549,
|
||||||
// 1548,
|
// 1548,
|
||||||
// 1547,
|
// 1547,
|
||||||
// 1546,
|
1546,
|
||||||
// 1545 NA
|
// 1545 NA
|
||||||
// 1544 NA
|
// 1544 NA
|
||||||
// 1543 NA
|
// 1543 NA
|
||||||
|
Reference in New Issue
Block a user