Patch 8.2.4834
Problem: Vim9: some lines not covered by tests.
Solution: Add a few more tests. Remove dead code.
Files: src/vim9execute.c, src/vim9instr.c, src/vim9.h,
src/testdir/test_vim9_expr.vim
*** ../vim-8.2.4833/src/vim9execute.c 2022-04-25 12:43:15.179819208 +0100
--- src/vim9execute.c 2022-04-27 17:51:33.151522497 +0100
***************
*** 3172,3177 ****
--- 3172,3178 ----
int idx = get_script_item_idx(sid, name, 0,
NULL, NULL);
+ // can this ever fail?
if (idx >= 0)
{
svar_T *sv = ((svar_T *)SCRIPT_ITEM(sid)
***************
*** 3862,3876 ****
case ISN_CATCH:
{
garray_T *trystack = &ectx->ec_trystack;
may_restore_cmdmod(&ectx->ec_funclocal);
! if (trystack->ga_len > 0)
! {
! trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - 1;
! trycmd->tcd_caught = TRUE;
! trycmd->tcd_did_throw = FALSE;
! }
did_emsg = got_int = did_throw = FALSE;
force_abort = need_rethrow = FALSE;
catch_exception(current_exception);
--- 3863,3876 ----
case ISN_CATCH:
{
garray_T *trystack = &ectx->ec_trystack;
+ trycmd_T *trycmd;
may_restore_cmdmod(&ectx->ec_funclocal);
! trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - 1;
! trycmd->tcd_caught = TRUE;
! trycmd->tcd_did_throw = FALSE;
!
did_emsg = got_int = did_throw = FALSE;
force_abort = need_rethrow = FALSE;
catch_exception(current_exception);
***************
*** 3924,3961 ****
case ISN_ENDTRY:
{
garray_T *trystack = &ectx->ec_trystack;
! if (trystack->ga_len > 0)
! {
! trycmd_T *trycmd;
!
! --trystack->ga_len;
! --trylevel;
! trycmd = ((trycmd_T *)trystack->ga_data)
! + trystack->ga_len;
! if (trycmd->tcd_did_throw)
! did_throw = TRUE;
! if (trycmd->tcd_caught && current_exception != NULL)
! {
! // discard the exception
! if (caught_stack == current_exception)
! caught_stack = caught_stack->caught;
! discard_current_exception();
! }
! if (trycmd->tcd_return)
! goto func_return;
! while (ectx->ec_stack.ga_len > trycmd->tcd_stack_len)
! {
! --ectx->ec_stack.ga_len;
! clear_tv(STACK_TV_BOT(0));
! }
! if (trycmd->tcd_cont != 0)
! // handling :continue: jump to outer try block or
! // start of the loop
! ectx->ec_iidx = trycmd->tcd_cont - 1;
}
}
break;
--- 3924,3956 ----
case ISN_ENDTRY:
{
garray_T *trystack = &ectx->ec_trystack;
+ trycmd_T *trycmd;
! --trystack->ga_len;
! --trylevel;
! trycmd = ((trycmd_T *)trystack->ga_data) + trystack->ga_len;
! if (trycmd->tcd_did_throw)
! did_throw = TRUE;
! if (trycmd->tcd_caught && current_exception != NULL)
! {
! // discard the exception
! if (caught_stack == current_exception)
! caught_stack = caught_stack->caught;
! discard_current_exception();
! }
! if (trycmd->tcd_return)
! goto func_return;
! while (ectx->ec_stack.ga_len > trycmd->tcd_stack_len)
! {
! --ectx->ec_stack.ga_len;
! clear_tv(STACK_TV_BOT(0));
}
+ if (trycmd->tcd_cont != 0)
+ // handling :continue: jump to outer try block or
+ // start of the loop
+ ectx->ec_iidx = trycmd->tcd_cont - 1;
}
break;
***************
*** 4021,4032 ****
varnumber_T arg2 = tv2->vval.v_number;
int res;
! switch (iptr->isn_arg.op.op_type)
! {
! case EXPR_EQUAL: res = arg1 == arg2; break;
! case EXPR_NEQUAL: res = arg1 != arg2; break;
! default: res = 0; break;
! }
--ectx->ec_stack.ga_len;
tv1->v_type = VAR_BOOL;
--- 4016,4025 ----
varnumber_T arg2 = tv2->vval.v_number;
int res;
! if (iptr->isn_arg.op.op_type == EXPR_EQUAL)
! res = arg1 == arg2;
! else
! res = arg1 != arg2;
--ectx->ec_stack.ga_len;
tv1->v_type = VAR_BOOL;
***************
*** 4658,4677 ****
tv->vval.v_number = -tv->vval.v_number;
break;
- case ISN_CHECKNR:
- {
- int error = FALSE;
-
- tv = STACK_TV_BOT(-1);
- SOURCING_LNUM = iptr->isn_lnum;
- if (check_not_string(tv) == FAIL)
- goto on_error;
- (void)tv_get_number_chk(tv, &error);
- if (error)
- goto on_error;
- }
- break;
-
case ISN_CHECKTYPE:
{
checktype_T *ct = &iptr->isn_arg.type;
--- 4651,4656 ----
***************
*** 4778,4787 ****
tv = STACK_TV_BOT(-1);
tv->v_type = VAR_NUMBER;
tv->v_lock = 0;
! if (ea.addr_count == 0)
! tv->vval.v_number = curwin->w_cursor.lnum;
! else
! tv->vval.v_number = ea.line2;
}
break;
--- 4757,4763 ----
tv = STACK_TV_BOT(-1);
tv->v_type = VAR_NUMBER;
tv->v_lock = 0;
! tv->vval.v_number = ea.line2;
}
break;
***************
*** 6144,6150 ****
case ISN_NEGATENR: smsg("%s%4d NEGATENR", pfx, current); break;
- case ISN_CHECKNR: smsg("%s%4d CHECKNR", pfx, current); break;
case ISN_CHECKTYPE:
{
checktype_T *ct = &iptr->isn_arg.type;
--- 6120,6125 ----
*** ../vim-8.2.4833/src/vim9instr.c 2022-04-25 12:43:15.179819208 +0100
--- src/vim9instr.c 2022-04-27 17:23:17.985338709 +0100
***************
*** 2231,2237 ****
case ISN_CATCH:
case ISN_CEXPR_AUCMD:
case ISN_CHECKLEN:
- case ISN_CHECKNR:
case ISN_CLEARDICT:
case ISN_CMDMOD_REV:
case ISN_COMPAREANY:
--- 2231,2236 ----
*** ../vim-8.2.4833/src/vim9.h 2022-04-25 12:43:15.175819215 +0100
--- src/vim9.h 2022-04-27 17:23:31.249331543 +0100
***************
*** 173,179 ****
ISN_2STRING_ANY, // like ISN_2STRING but check type
ISN_NEGATENR, // apply "-" to number
- ISN_CHECKNR, // check value can be used as a number
ISN_CHECKTYPE, // check value type is isn_arg.type.ct_type
ISN_CHECKLEN, // check list length is isn_arg.checklen.cl_min_len
ISN_SETTYPE, // set dict type to isn_arg.type.ct_type
--- 173,178 ----
*** ../vim-8.2.4833/src/testdir/test_vim9_expr.vim 2022-04-05
17:30:23.263606787 +0100
--- src/testdir/test_vim9_expr.vim 2022-04-27 17:18:13.049494250 +0100
***************
*** 1848,1855 ****
v9.CheckDefFailure(["var d = 6 * "], 'E1097:', 3)
v9.CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2)
! v9.CheckDefExecAndScriptFailure(['echo 1 / 0'], 'E1154', 1)
! v9.CheckDefExecAndScriptFailure(['echo 1 % 0'], 'E1154', 1)
if has('float')
v9.CheckDefExecAndScriptFailure([
--- 1848,1859 ----
v9.CheckDefFailure(["var d = 6 * "], 'E1097:', 3)
v9.CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2)
! v9.CheckDefAndScriptFailure(['echo 1 / 0'], 'E1154', 1)
! v9.CheckDefAndScriptFailure(['echo 1 % 0'], 'E1154', 1)
!
! g:zero = 0
! v9.CheckDefExecFailure(['echo 123 / g:zero'], 'E1154: Divide by zero')
! v9.CheckDefExecFailure(['echo 123 % g:zero'], 'E1154: Divide by zero')
if has('float')
v9.CheckDefExecAndScriptFailure([
***************
*** 3398,3403 ****
--- 3402,3416 ----
lines =<< trim END
vim9script
+ def GetNumber(): number
+ legacy return notexists
+ enddef
+ echo GetNumber()
+ END
+ v9.CheckScriptFailure(lines, 'E121: Undefined variable: notexists')
+
+ lines =<< trim END
+ vim9script
def GetNumber(): number
legacy return range(3)->map('v:val + 1')
enddef
*** ../vim-8.2.4833/src/version.c 2022-04-27 11:57:57.581002707 +0100
--- src/version.c 2022-04-27 16:53:19.990001302 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4834,
/**/
--
Q: How many legs does a giraffe have?
A: Eight: two in front, two behind, two on the left and two on the right
/// 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/20220427165453.E43FA1C0761%40moolenaar.net.