Mercurial > vim
changeset 20419:d54dfb5f12db v8.2.0764
patch 8.2.0764: Vim9: assigning to option not fully tested
Commit: https://github.com/vim/vim/commit/a6e67e4f41386c3e6eab7e047671c6d32f6cb0dc
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 15 23:36:40 2020 +0200
patch 8.2.0764: Vim9: assigning to option not fully tested
Problem: Vim9: assigning to option not fully tested.
Solution: Add more test cases. Allow using any type for assignment.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 15 May 2020 23:45:04 +0200 |
parents | 2005771741d3 |
children | e5482a10499c |
files | src/testdir/test_vim9_script.vim src/version.c src/vim9compile.c src/vim9execute.c |
diffstat | 4 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -14,6 +14,8 @@ let s:addToMe = 111 let g:existing = 'yes' let g:inc_counter = 1 let $SOME_ENV_VAR = 'some' +let g:alist = [7] +let g:astring = 'text' def Test_assignment() let bool1: bool = true @@ -95,7 +97,12 @@ def Test_assignment() assert_equal(2, &ts) call CheckDefFailure(['¬ex += 3'], 'E113:') call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') + call CheckDefFailure(['&ts = [7]'], 'E1013:') + call CheckDefExecFailure(['&ts = g:alist'], 'E1029: Expected number but got list') + call CheckDefFailure(['&ts = "xx"'], 'E1013:') + call CheckDefExecFailure(['&ts = g:astring'], 'E1029: Expected number but got string') call CheckDefFailure(['&path += 3'], 'E1013:') + call CheckDefExecFailure(['&bs = "asdf"'], 'E474:') # test freeing ISN_STOREOPT call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:') &ts = 8
--- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 764, +/**/ 763, /**/ 762,
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -3490,7 +3490,7 @@ compile_subscript( type_T **typep; // list index: list[123] - // list member: dict[key] + // dict member: dict[key] // TODO: blob index // TODO: more arguments // TODO: recognize list or dict at runtime @@ -4999,8 +4999,8 @@ compile_assignment(char_u *arg, exarg_T goto theend; } } - else if (*p != '=' && check_type(member_type, stacktype, TRUE) - == FAIL) + else if (*p != '=' && need_type(stacktype, member_type, -1, + cctx) == FAIL) goto theend; } }
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -1164,13 +1164,9 @@ call_def_function( if (s == NULL) s = (char_u *)""; } - else if (tv->v_type == VAR_NUMBER) + else + // must be VAR_NUMBER, CHECKTYPE makes sure n = tv->vval.v_number; - else - { - emsg(_("E1051: Expected string or number")); - goto failed; - } msg = set_option_value(iptr->isn_arg.storeopt.so_name, n, s, iptr->isn_arg.storeopt.so_flags); if (msg != NULL)