comparison src/vim9execute.c @ 28621:333be301dfe8 v8.2.4834

patch 8.2.4834: Vim9: some lines not covered by tests Commit: https://github.com/vim/vim/commit/06651630ee35111839e627e1bcbac94b86347883 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 27 17:54:25 2022 +0100 patch 8.2.4834: Vim9: some lines not covered by tests Problem: Vim9: some lines not covered by tests. Solution: Add a few more tests. Remove dead code.
author Bram Moolenaar <Bram@vim.org>
date Wed, 27 Apr 2022 19:00:03 +0200
parents d550054e1328
children 1d92ba691dc4
comparison
equal deleted inserted replaced
28620:4d76b3e07c07 28621:333be301dfe8
3170 if (iptr->isn_type == ISN_STOREEXPORT) 3170 if (iptr->isn_type == ISN_STOREEXPORT)
3171 { 3171 {
3172 int idx = get_script_item_idx(sid, name, 0, 3172 int idx = get_script_item_idx(sid, name, 0,
3173 NULL, NULL); 3173 NULL, NULL);
3174 3174
3175 // can this ever fail?
3175 if (idx >= 0) 3176 if (idx >= 0)
3176 { 3177 {
3177 svar_T *sv = ((svar_T *)SCRIPT_ITEM(sid) 3178 svar_T *sv = ((svar_T *)SCRIPT_ITEM(sid)
3178 ->sn_var_vals.ga_data) + idx; 3179 ->sn_var_vals.ga_data) + idx;
3179 3180
3860 break; 3861 break;
3861 3862
3862 case ISN_CATCH: 3863 case ISN_CATCH:
3863 { 3864 {
3864 garray_T *trystack = &ectx->ec_trystack; 3865 garray_T *trystack = &ectx->ec_trystack;
3866 trycmd_T *trycmd;
3865 3867
3866 may_restore_cmdmod(&ectx->ec_funclocal); 3868 may_restore_cmdmod(&ectx->ec_funclocal);
3867 if (trystack->ga_len > 0) 3869 trycmd = ((trycmd_T *)trystack->ga_data)
3868 {
3869 trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
3870 + trystack->ga_len - 1; 3870 + trystack->ga_len - 1;
3871 trycmd->tcd_caught = TRUE; 3871 trycmd->tcd_caught = TRUE;
3872 trycmd->tcd_did_throw = FALSE; 3872 trycmd->tcd_did_throw = FALSE;
3873 } 3873
3874 did_emsg = got_int = did_throw = FALSE; 3874 did_emsg = got_int = did_throw = FALSE;
3875 force_abort = need_rethrow = FALSE; 3875 force_abort = need_rethrow = FALSE;
3876 catch_exception(current_exception); 3876 catch_exception(current_exception);
3877 } 3877 }
3878 break; 3878 break;
3922 3922
3923 // end of ":try" block 3923 // end of ":try" block
3924 case ISN_ENDTRY: 3924 case ISN_ENDTRY:
3925 { 3925 {
3926 garray_T *trystack = &ectx->ec_trystack; 3926 garray_T *trystack = &ectx->ec_trystack;
3927 3927 trycmd_T *trycmd;
3928 if (trystack->ga_len > 0) 3928
3929 { 3929 --trystack->ga_len;
3930 trycmd_T *trycmd; 3930 --trylevel;
3931 3931 trycmd = ((trycmd_T *)trystack->ga_data) + trystack->ga_len;
3932 --trystack->ga_len; 3932 if (trycmd->tcd_did_throw)
3933 --trylevel; 3933 did_throw = TRUE;
3934 trycmd = ((trycmd_T *)trystack->ga_data) 3934 if (trycmd->tcd_caught && current_exception != NULL)
3935 + trystack->ga_len; 3935 {
3936 if (trycmd->tcd_did_throw) 3936 // discard the exception
3937 did_throw = TRUE; 3937 if (caught_stack == current_exception)
3938 if (trycmd->tcd_caught && current_exception != NULL) 3938 caught_stack = caught_stack->caught;
3939 { 3939 discard_current_exception();
3940 // discard the exception 3940 }
3941 if (caught_stack == current_exception) 3941
3942 caught_stack = caught_stack->caught; 3942 if (trycmd->tcd_return)
3943 discard_current_exception(); 3943 goto func_return;
3944 } 3944
3945 3945 while (ectx->ec_stack.ga_len > trycmd->tcd_stack_len)
3946 if (trycmd->tcd_return) 3946 {
3947 goto func_return; 3947 --ectx->ec_stack.ga_len;
3948 3948 clear_tv(STACK_TV_BOT(0));
3949 while (ectx->ec_stack.ga_len > trycmd->tcd_stack_len) 3949 }
3950 { 3950 if (trycmd->tcd_cont != 0)
3951 --ectx->ec_stack.ga_len; 3951 // handling :continue: jump to outer try block or
3952 clear_tv(STACK_TV_BOT(0)); 3952 // start of the loop
3953 } 3953 ectx->ec_iidx = trycmd->tcd_cont - 1;
3954 if (trycmd->tcd_cont != 0)
3955 // handling :continue: jump to outer try block or
3956 // start of the loop
3957 ectx->ec_iidx = trycmd->tcd_cont - 1;
3958 }
3959 } 3954 }
3960 break; 3955 break;
3961 3956
3962 case ISN_THROW: 3957 case ISN_THROW:
3963 { 3958 {
4019 typval_T *tv2 = STACK_TV_BOT(-1); 4014 typval_T *tv2 = STACK_TV_BOT(-1);
4020 varnumber_T arg1 = tv1->vval.v_number; 4015 varnumber_T arg1 = tv1->vval.v_number;
4021 varnumber_T arg2 = tv2->vval.v_number; 4016 varnumber_T arg2 = tv2->vval.v_number;
4022 int res; 4017 int res;
4023 4018
4024 switch (iptr->isn_arg.op.op_type) 4019 if (iptr->isn_arg.op.op_type == EXPR_EQUAL)
4025 { 4020 res = arg1 == arg2;
4026 case EXPR_EQUAL: res = arg1 == arg2; break; 4021 else
4027 case EXPR_NEQUAL: res = arg1 != arg2; break; 4022 res = arg1 != arg2;
4028 default: res = 0; break;
4029 }
4030 4023
4031 --ectx->ec_stack.ga_len; 4024 --ectx->ec_stack.ga_len;
4032 tv1->v_type = VAR_BOOL; 4025 tv1->v_type = VAR_BOOL;
4033 tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE; 4026 tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE;
4034 } 4027 }
4656 else 4649 else
4657 #endif 4650 #endif
4658 tv->vval.v_number = -tv->vval.v_number; 4651 tv->vval.v_number = -tv->vval.v_number;
4659 break; 4652 break;
4660 4653
4661 case ISN_CHECKNR:
4662 {
4663 int error = FALSE;
4664
4665 tv = STACK_TV_BOT(-1);
4666 SOURCING_LNUM = iptr->isn_lnum;
4667 if (check_not_string(tv) == FAIL)
4668 goto on_error;
4669 (void)tv_get_number_chk(tv, &error);
4670 if (error)
4671 goto on_error;
4672 }
4673 break;
4674
4675 case ISN_CHECKTYPE: 4654 case ISN_CHECKTYPE:
4676 { 4655 {
4677 checktype_T *ct = &iptr->isn_arg.type; 4656 checktype_T *ct = &iptr->isn_arg.type;
4678 4657
4679 tv = STACK_TV_BOT((int)ct->ct_off); 4658 tv = STACK_TV_BOT((int)ct->ct_off);
4776 goto theend; 4755 goto theend;
4777 ++ectx->ec_stack.ga_len; 4756 ++ectx->ec_stack.ga_len;
4778 tv = STACK_TV_BOT(-1); 4757 tv = STACK_TV_BOT(-1);
4779 tv->v_type = VAR_NUMBER; 4758 tv->v_type = VAR_NUMBER;
4780 tv->v_lock = 0; 4759 tv->v_lock = 0;
4781 if (ea.addr_count == 0) 4760 tv->vval.v_number = ea.line2;
4782 tv->vval.v_number = curwin->w_cursor.lnum;
4783 else
4784 tv->vval.v_number = ea.line2;
4785 } 4761 }
4786 break; 4762 break;
4787 4763
4788 case ISN_PUT: 4764 case ISN_PUT:
4789 { 4765 {
6142 case ISN_CLEARDICT: smsg("%s%4d CLEARDICT", pfx, current); break; 6118 case ISN_CLEARDICT: smsg("%s%4d CLEARDICT", pfx, current); break;
6143 case ISN_USEDICT: smsg("%s%4d USEDICT", pfx, current); break; 6119 case ISN_USEDICT: smsg("%s%4d USEDICT", pfx, current); break;
6144 6120
6145 case ISN_NEGATENR: smsg("%s%4d NEGATENR", pfx, current); break; 6121 case ISN_NEGATENR: smsg("%s%4d NEGATENR", pfx, current); break;
6146 6122
6147 case ISN_CHECKNR: smsg("%s%4d CHECKNR", pfx, current); break;
6148 case ISN_CHECKTYPE: 6123 case ISN_CHECKTYPE:
6149 { 6124 {
6150 checktype_T *ct = &iptr->isn_arg.type; 6125 checktype_T *ct = &iptr->isn_arg.type;
6151 char *tofree; 6126 char *tofree;
6152 6127