From a3dc7ef44577dc4708ac7b4c329c1620770aadc3 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 13 Jul 2016 16:49:22 +1000 Subject: [PATCH 1/3] vim-patch:7.4.1546 Problem: Sticky type checking is more annoying than useful. Solution: Remove the error for changing a variable type. https://github.com/vim/vim/commit/f6f32c38bf3319144a84a01a154c8c91939e7acf Note: There are a bunch of other changes to eval.txt that I believe are N/A and not related to this patch. --- runtime/doc/eval.txt | 15 +++------------ src/nvim/eval.c | 15 +-------------- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_assign.vim | 9 +++++++++ src/nvim/version.c | 2 +- 5 files changed, 15 insertions(+), 27 deletions(-) create mode 100644 src/nvim/testdir/test_assign.vim diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0ca41370e9..efb8da0cfa 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -103,18 +103,9 @@ to Float, printf() for Float to String and float2nr() for Float to Number. *E891* *E892* *E893* *E894* When expecting a Float a Number can also be used, but nothing else. - *E706* *sticky-type-checking* -You will get an error if you try to change the type of a variable. You need -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! - - + *no-type-checking* +You will not get an error if you try to change the type of a variable. + 1.2 Function references ~ *Funcref* *E695* *E718* A Funcref variable is obtained with the |function()| function. It can be used diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 47d44b148a..a43a389478 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -18886,19 +18886,6 @@ set_var ( || tv_check_lock(v->di_tv.v_lock, name, false)) { 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 // prevent changing the type. @@ -18908,7 +18895,7 @@ set_var ( if (copy || tv->v_type != VAR_STRING) v->di_tv.vval.v_string = vim_strsave(get_tv_string(tv)); 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; tv->vval.v_string = NULL; } diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 4b0b5e8d26..30923101bc 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -33,6 +33,7 @@ SCRIPTS := \ # Tests using runtest.vim.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS = \ + test_assign.res \ test_cursor_func.res \ test_hardcopy.res \ test_help_tagjump.res \ diff --git a/src/nvim/testdir/test_assign.vim b/src/nvim/testdir/test_assign.vim new file mode 100644 index 0000000000..3d2e7a8998 --- /dev/null +++ b/src/nvim/testdir/test_assign.vim @@ -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 diff --git a/src/nvim/version.c b/src/nvim/version.c index 966e4f9b4f..e45d61014e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -153,7 +153,7 @@ static int included_patches[] = { // 1549, // 1548, // 1547, - // 1546, + 1546, // 1545 NA // 1544 NA // 1543 NA From 98fb0f12c4c447b70bbef3004bb1657887537d5c Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 13 Jul 2016 17:56:58 +1000 Subject: [PATCH 2/3] vim-patch:7.4.1548 Problem: Two tests fail. Solution: Adjust the expected error number. Remove check for type. https://github.com/vim/vim/commit/5a2800fd141a8fc0c80cdf421dcb76001a22327f --- src/nvim/version.c | 2 +- .../legacy/055_list_and_dict_types_spec.lua | 23 ------------------- test/functional/legacy/101_hlsearch_spec.lua | 2 +- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/nvim/version.c b/src/nvim/version.c index e45d61014e..5fdbb7db57 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -151,7 +151,7 @@ static int included_patches[] = { 1551, 1550, // 1549, - // 1548, + 1548, // 1547, 1546, // 1545 NA diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua index dee138e6d8..b9e5a8bc03 100644 --- a/test/functional/legacy/055_list_and_dict_types_spec.lua +++ b/test/functional/legacy/055_list_and_dict_types_spec.lua @@ -112,29 +112,6 @@ describe('list and dictionary types', function() expect('\n101101') end) - it('changing var type should fail', function() - source([[ - lang C - " The list from the first test repeated after splitting the tests. - let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},] - " The dict from the first test repeated after splitting the tests. - let d = {'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}} - try - let d = [] - catch - $put =v:exception[:14] . v:exception[-1:-1] - endtry - try - let l = {} - catch - $put =v:exception[:14] . v:exception[-1:-1] - endtry]]) - expect([[ - - Vim(let):E706: d - Vim(let):E706: l]]) - end) - it('removing items with :unlet', function() source([[ lang C diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua index 0d88e99278..fa29e5fbe8 100644 --- a/test/functional/legacy/101_hlsearch_spec.lua +++ b/test/functional/legacy/101_hlsearch_spec.lua @@ -61,6 +61,6 @@ describe('v:hlsearch', function() 0:not highlighted 1:highlighted 0:not highlighted - Vim(let):E706:]]) + Vim(let):E745:]]) end) end) From 9c3bd3e427686855a8e75403d1715dd4b99ffa8a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 18 Jul 2016 11:17:16 -0400 Subject: [PATCH 3/3] test: Update test_alot.vim These tests should be here, not in the Makefile. --- src/nvim/testdir/Makefile | 4 ---- src/nvim/testdir/test_alot.vim | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 30923101bc..30f5170565 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -33,15 +33,11 @@ SCRIPTS := \ # Tests using runtest.vim.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS = \ - test_assign.res \ - test_cursor_func.res \ test_hardcopy.res \ test_help_tagjump.res \ test_langmap.res \ - test_menu.res \ test_syntax.res \ test_timers.res \ - test_unlet.res \ test_viml.res \ test_alot.res diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 1d1da94bac..ad9b2cce8b 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -1,3 +1,7 @@ " A series of tests that can run in one Vim invocation. " This makes testing go faster, since Vim doesn't need to restart. +source test_assign.vim +source test_cursor_func.vim +source test_menu.vim +source test_unlet.vim