Patch 8.2.4410
Problem: Vim9: some code not covered by tests.
Solution: Add a few more tests. Remove dead code.
Files: src/vim9execute.c, src/testdir/test_vim9_assign.vim,
src/testdir/test_vim9_cmd.vim, src/testdir/test_vim9_expr.vim,
src/testdir/test_vim9_script.vim
*** ../vim-8.2.4409/src/vim9execute.c 2022-02-17 16:30:07.772148419 +0000
--- src/vim9execute.c 2022-02-17 19:32:15.696741310 +0000
***************
*** 2331,2349 ****
}
di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
- if (di == NULL && ht == get_globvar_ht()
- && vim_strchr(iptr->isn_arg.string,
- AUTOLOAD_CHAR) != NULL)
- {
- // Global variable has an autoload name, may still need
- // to load the script.
- if (script_autoload(iptr->isn_arg.string, FALSE))
- di = find_var_in_ht(ht, 0,
- iptr->isn_arg.string, TRUE);
- if (did_emsg)
- return FAIL;
- }
-
if (di == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
--- 2331,2336 ----
***************
*** 2520,2533 ****
ea.cmdidx = CMD_SIZE;
ea.addr_type = ADDR_LINES;
ea.cmd = iptr->isn_arg.string;
parse_cmd_address(&ea, &error, FALSE);
if (ea.cmd == NULL)
goto on_error;
! if (error == NULL)
! error = ex_range_without_command(&ea);
if (error != NULL)
{
- SOURCING_LNUM = iptr->isn_lnum;
emsg(error);
goto on_error;
}
--- 2507,2520 ----
ea.cmdidx = CMD_SIZE;
ea.addr_type = ADDR_LINES;
ea.cmd = iptr->isn_arg.string;
+ SOURCING_LNUM = iptr->isn_lnum;
parse_cmd_address(&ea, &error, FALSE);
if (ea.cmd == NULL)
goto on_error;
! // error is always NULL when using ADDR_LINES
! error = ex_range_without_command(&ea);
if (error != NULL)
{
emsg(error);
goto on_error;
}
***************
*** 3566,3577 ****
{
ufunc = find_func(funcref->fr_func_name, FALSE);
}
- if (ufunc == NULL)
- {
- SOURCING_LNUM = iptr->isn_lnum;
- emsg(_(e_function_reference_invalid));
- goto theend;
- }
if (fill_partial_and_closure(pt, ufunc, ectx) == FAIL)
goto theend;
tv = STACK_TV_BOT(0);
--- 3553,3558 ----
***************
*** 4488,4503 ****
case ISN_NEGATENR:
tv = STACK_TV_BOT(-1);
! if (tv->v_type != VAR_NUMBER
! #ifdef FEAT_FLOAT
! && tv->v_type != VAR_FLOAT
! #endif
! )
! {
! SOURCING_LNUM = iptr->isn_lnum;
! emsg(_(e_number_expected));
! goto on_error;
! }
#ifdef FEAT_FLOAT
if (tv->v_type == VAR_FLOAT)
tv->vval.v_float = -tv->vval.v_float;
--- 4469,4475 ----
case ISN_NEGATENR:
tv = STACK_TV_BOT(-1);
! // CHECKTYPE should have checked the variable type
#ifdef FEAT_FLOAT
if (tv->v_type == VAR_FLOAT)
tv->vval.v_float = -tv->vval.v_float;
*** ../vim-8.2.4409/src/testdir/test_vim9_assign.vim 2022-02-17
16:30:07.772148419 +0000
--- src/testdir/test_vim9_assign.vim 2022-02-17 18:15:22.637114560 +0000
***************
*** 2104,2109 ****
--- 2104,2116 ----
unlet ll[-2 : -1]
assert_equal([1, 2], ll)
+ g:nrdict = {1: 1, 2: 2}
+ g:idx = 1
+ unlet g:nrdict[g:idx]
+ assert_equal({2: 2}, g:nrdict)
+ unlet g:nrdict
+ unlet g:idx
+
v9.CheckDefFailure([
'var ll = [1, 2]',
'll[1 : 2] = 7',
*** ../vim-8.2.4409/src/testdir/test_vim9_cmd.vim 2022-02-17
13:08:22.955193271 +0000
--- src/testdir/test_vim9_cmd.vim 2022-02-17 18:46:09.214543463 +0000
***************
*** 1552,1557 ****
--- 1552,1579 ----
v9.CheckScriptFailure(lines, 'E1119', 4)
lines =<< trim END
+ vim9script
+ var theList = [1, 2, 3]
+ def AddToList()
+ lockvar theList
+ theList += [4]
+ enddef
+ AddToList()
+ END
+ v9.CheckScriptFailure(lines, 'E741', 2)
+
+ lines =<< trim END
+ vim9script
+ var theList = [1, 2, 3]
+ def AddToList()
+ lockvar theList
+ add(theList, 4)
+ enddef
+ AddToList()
+ END
+ v9.CheckScriptFailure(lines, 'E741', 2)
+
+ lines =<< trim END
var theList = [1, 2, 3]
lockvar theList
END
*** ../vim-8.2.4409/src/testdir/test_vim9_expr.vim 2022-02-12
19:52:22.028702244 +0000
--- src/testdir/test_vim9_expr.vim 2022-02-17 19:26:35.505499686 +0000
***************
*** 1556,1561 ****
--- 1556,1569 ----
v9.CheckDefExecAndScriptFailure(['echo 1 / 0'], 'E1154', 1)
v9.CheckDefExecAndScriptFailure(['echo 1 % 0'], 'E1154', 1)
+ if has('float')
+ v9.CheckDefExecAndScriptFailure([
+ 'g:one = 1.0'
+ 'g:two = 2.0'
+ 'echo g:one % g:two'
+ ], 'E804', 3)
+ endif
+
lines =<< trim END
var n = 0
eval 1 / n
*** ../vim-8.2.4409/src/testdir/test_vim9_script.vim 2022-02-13
13:56:25.802074076 +0000
--- src/testdir/test_vim9_script.vim 2022-02-17 17:53:32.714717364 +0000
***************
*** 52,57 ****
--- 52,66 ----
bwipe!
+ lines =<< trim END
+ set cpo+=-
+ :1,999
+ END
+ v9.CheckDefExecAndScriptFailure(lines, 'E16:', 2)
+ set cpo&vim
+
+ v9.CheckDefExecAndScriptFailure([":'x"], 'E20:', 1)
+
# won't generate anything
if false
:123
***************
*** 1726,1731 ****
--- 1735,1743 ----
v9.CheckDefFailure(['execute xxx'], 'E1001:', 1)
v9.CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1)
v9.CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1)
+ if has('channel')
+ v9.CheckDefExecFailure(['execute test_null_channel()'], 'E908:', 1)
+ endif
enddef
def Test_execute_cmd_vimscript()
*** ../vim-8.2.4409/src/version.c 2022-02-17 16:30:07.772148419 +0000
--- src/version.c 2022-02-17 18:15:54.733078668 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4410,
/**/
--
hundred-and-one symptoms of being an internet addict:
60. As your car crashes through the guardrail on a mountain road, your first
instinct is to search for the "back" button.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220217194451.304B21C0FE0%40moolenaar.net.