Patch 8.2.2868
Problem:    Vim9: When executing a compiled expression the trylevel at start
            is changed but not restored. (closes #8214)
Solution:   Restore the trylevel at start.
Files:      src/vim9execute.c, src/testdir/test_vim9_builtin.vim


*** ../vim-8.2.2867/src/vim9execute.c   2021-05-17 00:01:38.803009279 +0200
--- src/vim9execute.c   2021-05-18 17:39:36.007287664 +0200
***************
*** 1291,1296 ****
--- 1291,1298 ----
  {
      int               breakcheck_count = 0;
      typval_T  *tv;
+     int               ret = FAIL;
+     int               save_trylevel_at_start = ectx->ec_trylevel_at_start;
  
      // Start execution at the first instruction.
      ectx->ec_iidx = 0;
***************
*** 1312,1318 ****
            // Turn CTRL-C into an exception.
            got_int = FALSE;
            if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) == FAIL)
!               return FAIL;
            did_throw = TRUE;
        }
  
--- 1314,1320 ----
            // Turn CTRL-C into an exception.
            got_int = FALSE;
            if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) == FAIL)
!               goto theend;
            did_throw = TRUE;
        }
  
***************
*** 1321,1327 ****
            // Turn an error message into an exception.
            did_emsg = FALSE;
            if (throw_exception(*msg_list, ET_ERROR, NULL) == FAIL)
!               return FAIL;
            did_throw = TRUE;
            *msg_list = NULL;
        }
--- 1323,1329 ----
            // Turn an error message into an exception.
            did_emsg = FALSE;
            if (throw_exception(*msg_list, ET_ERROR, NULL) == FAIL)
!               goto theend;
            did_throw = TRUE;
            *msg_list = NULL;
        }
***************
*** 1346,1352 ****
                // Not inside try or need to return from current functions.
                // Push a dummy return value.
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   return FAIL;
                tv = STACK_TV_BOT(0);
                tv->v_type = VAR_NUMBER;
                tv->vval.v_number = 0;
--- 1348,1354 ----
                // Not inside try or need to return from current functions.
                // Push a dummy return value.
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   goto theend;
                tv = STACK_TV_BOT(0);
                tv->v_type = VAR_NUMBER;
                tv->vval.v_number = 0;
***************
*** 1356,1367 ****
                    // At the toplevel we are done.
                    need_rethrow = TRUE;
                    if (handle_closure_in_use(ectx, FALSE) == FAIL)
!                       return FAIL;
                    goto done;
                }
  
                if (func_return(ectx) == FAIL)
!                   return FAIL;
            }
            continue;
        }
--- 1358,1369 ----
                    // At the toplevel we are done.
                    need_rethrow = TRUE;
                    if (handle_closure_in_use(ectx, FALSE) == FAIL)
!                       goto theend;
                    goto done;
                }
  
                if (func_return(ectx) == FAIL)
!                   goto theend;
            }
            continue;
        }
***************
*** 1397,1403 ****
                    int     save_flags = cmdmod.cmod_flags;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    tv = STACK_TV_BOT(0);
                    init_tv(tv);
                    cmdmod.cmod_flags |= CMOD_LEGACY;
--- 1399,1405 ----
                    int     save_flags = cmdmod.cmod_flags;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    tv = STACK_TV_BOT(0);
                    init_tv(tv);
                    cmdmod.cmod_flags |= CMOD_LEGACY;
***************
*** 1413,1419 ****
            case ISN_INSTR:
                {
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    tv = STACK_TV_BOT(0);
                    tv->vval.v_instr = ALLOC_ONE(instr_T);
                    if (tv->vval.v_instr == NULL)
--- 1415,1421 ----
            case ISN_INSTR:
                {
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    tv = STACK_TV_BOT(0);
                    tv->vval.v_instr = ALLOC_ONE(instr_T);
                    if (tv->vval.v_instr == NULL)
***************
*** 1480,1486 ****
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
                    {
                        vim_free(res);
!                       return FAIL;
                    }
                    tv = STACK_TV_BOT(0);
                    tv->v_type = VAR_STRING;
--- 1482,1488 ----
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
                    {
                        vim_free(res);
!                       goto theend;
                    }
                    tv = STACK_TV_BOT(0);
                    tv->v_type = VAR_STRING;
***************
*** 1545,1551 ****
                        {
                            cmd = alloc(len + 1);
                            if (cmd == NULL)
!                               return FAIL;
                            len = 0;
                        }
                    }
--- 1547,1553 ----
                        {
                            cmd = alloc(len + 1);
                            if (cmd == NULL)
!                               goto theend;
                            len = 0;
                        }
                    }
***************
*** 1665,1671 ****
            // load local variable or argument
            case ISN_LOAD:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   return FAIL;
                copy_tv(STACK_TV_VAR(iptr->isn_arg.number), STACK_TV_BOT(0));
                ++ectx->ec_stack.ga_len;
                break;
--- 1667,1673 ----
            // load local variable or argument
            case ISN_LOAD:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   goto theend;
                copy_tv(STACK_TV_VAR(iptr->isn_arg.number), STACK_TV_BOT(0));
                ++ectx->ec_stack.ga_len;
                break;
***************
*** 1673,1679 ****
            // load v: variable
            case ISN_LOADV:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   return FAIL;
                copy_tv(get_vim_var_tv(iptr->isn_arg.number), STACK_TV_BOT(0));
                ++ectx->ec_stack.ga_len;
                break;
--- 1675,1681 ----
            // load v: variable
            case ISN_LOADV:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   goto theend;
                copy_tv(get_vim_var_tv(iptr->isn_arg.number), STACK_TV_BOT(0));
                ++ectx->ec_stack.ga_len;
                break;
***************
*** 1686,1695 ****
  
                    sv = get_script_svar(sref, ectx);
                    if (sv == NULL)
!                       return FAIL;
                    allocate_if_null(sv->sv_tv);
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    copy_tv(sv->sv_tv, STACK_TV_BOT(0));
                    ++ectx->ec_stack.ga_len;
                }
--- 1688,1697 ----
  
                    sv = get_script_svar(sref, ectx);
                    if (sv == NULL)
!                       goto theend;
                    allocate_if_null(sv->sv_tv);
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    copy_tv(sv->sv_tv, STACK_TV_BOT(0));
                    ++ectx->ec_stack.ga_len;
                }
***************
*** 1712,1718 ****
                    else
                    {
                        if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                           return FAIL;
                        copy_tv(&di->di_tv, STACK_TV_BOT(0));
                        ++ectx->ec_stack.ga_len;
                    }
--- 1714,1720 ----
                    else
                    {
                        if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                           goto theend;
                        copy_tv(&di->di_tv, STACK_TV_BOT(0));
                        ++ectx->ec_stack.ga_len;
                    }
***************
*** 1748,1754 ****
                            namespace = 't';
                            break;
                        default:  // Cannot reach here
!                           return FAIL;
                    }
                    di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
  
--- 1750,1756 ----
                            namespace = 't';
                            break;
                        default:  // Cannot reach here
!                           goto theend;
                    }
                    di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
  
***************
*** 1762,1768 ****
                    else
                    {
                        if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                           return FAIL;
                        copy_tv(&di->di_tv, STACK_TV_BOT(0));
                        ++ectx->ec_stack.ga_len;
                    }
--- 1764,1770 ----
                    else
                    {
                        if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                           goto theend;
                        copy_tv(&di->di_tv, STACK_TV_BOT(0));
                        ++ectx->ec_stack.ga_len;
                    }
***************
*** 1775,1781 ****
                    char_u *name = iptr->isn_arg.string;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    SOURCING_LNUM = iptr->isn_lnum;
                    if (eval_variable(name, (int)STRLEN(name),
                              STACK_TV_BOT(0), NULL, EVAL_VAR_VERBOSE) == FAIL)
--- 1777,1783 ----
                    char_u *name = iptr->isn_arg.string;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    SOURCING_LNUM = iptr->isn_lnum;
                    if (eval_variable(name, (int)STRLEN(name),
                              STACK_TV_BOT(0), NULL, EVAL_VAR_VERBOSE) == FAIL)
***************
*** 1799,1808 ****
                        case ISN_LOADWDICT: d = curwin->w_vars; break;
                        case ISN_LOADTDICT: d = curtab->tp_vars; break;
                        default:  // Cannot reach here
!                           return FAIL;
                    }
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    tv = STACK_TV_BOT(0);
                    tv->v_type = VAR_DICT;
                    tv->v_lock = 0;
--- 1801,1810 ----
                        case ISN_LOADWDICT: d = curwin->w_vars; break;
                        case ISN_LOADTDICT: d = curtab->tp_vars; break;
                        default:  // Cannot reach here
!                           goto theend;
                    }
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    tv = STACK_TV_BOT(0);
                    tv->v_type = VAR_DICT;
                    tv->v_lock = 0;
***************
*** 1821,1829 ****
                    // This is not expected to fail, name is checked during
                    // compilation: don't set SOURCING_LNUM.
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    if (eval_option(&name, &optval, TRUE) == FAIL)
!                       return FAIL;
                    *STACK_TV_BOT(0) = optval;
                    ++ectx->ec_stack.ga_len;
                }
--- 1823,1831 ----
                    // This is not expected to fail, name is checked during
                    // compilation: don't set SOURCING_LNUM.
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    if (eval_option(&name, &optval, TRUE) == FAIL)
!                       goto theend;
                    *STACK_TV_BOT(0) = optval;
                    ++ectx->ec_stack.ga_len;
                }
***************
*** 1836,1842 ****
                    char_u      *name = iptr->isn_arg.string;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    // name is always valid, checked when compiling
                    (void)eval_env_var(&name, &optval, TRUE);
                    *STACK_TV_BOT(0) = optval;
--- 1838,1844 ----
                    char_u      *name = iptr->isn_arg.string;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    // name is always valid, checked when compiling
                    (void)eval_env_var(&name, &optval, TRUE);
                    *STACK_TV_BOT(0) = optval;
***************
*** 1847,1853 ****
            // load @register
            case ISN_LOADREG:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   return FAIL;
                tv = STACK_TV_BOT(0);
                tv->v_type = VAR_STRING;
                tv->v_lock = 0;
--- 1849,1855 ----
            // load @register
            case ISN_LOADREG:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   goto theend;
                tv = STACK_TV_BOT(0);
                tv->v_type = VAR_STRING;
                tv->v_lock = 0;
***************
*** 1899,1905 ****
  
                    sv = get_script_svar(sref, ectx);
                    if (sv == NULL)
!                       return FAIL;
                    --ectx->ec_stack.ga_len;
  
                    // "const" and "final" are checked at compile time, locking
--- 1901,1907 ----
  
                    sv = get_script_svar(sref, ectx);
                    if (sv == NULL)
!                       goto theend;
                    --ectx->ec_stack.ga_len;
  
                    // "const" and "final" are checked at compile time, locking
***************
*** 2001,2007 ****
                            ht = &curtab->tp_vars->dv_hashtab;
                            break;
                        default:  // Cannot reach here
!                           return FAIL;
                    }
  
                    --ectx->ec_stack.ga_len;
--- 2003,2009 ----
                            ht = &curtab->tp_vars->dv_hashtab;
                            break;
                        default:  // Cannot reach here
!                           goto theend;
                    }
  
                    --ectx->ec_stack.ga_len;
***************
*** 2106,2112 ****
                                goto on_error;
                            // append to list, only fails when out of memory
                            if (list_append_tv(list, tv) == FAIL)
!                               return FAIL;
                            clear_tv(tv);
                        }
                    }
--- 2108,2114 ----
                                goto on_error;
                            // append to list, only fails when out of memory
                            if (list_append_tv(list, tv) == FAIL)
!                               goto theend;
                            clear_tv(tv);
                        }
                    }
***************
*** 2141,2147 ****
                                goto on_error;
                            // add to dict, only fails when out of memory
                            if (dict_add_tv(dict, (char *)key, tv) == FAIL)
!                               return FAIL;
                            clear_tv(tv);
                        }
                    }
--- 2143,2149 ----
                                goto on_error;
                            // add to dict, only fails when out of memory
                            if (dict_add_tv(dict, (char *)key, tv) == FAIL)
!                               goto theend;
                            clear_tv(tv);
                        }
                    }
***************
*** 2274,2280 ****
                    {
                        SOURCING_LNUM = iptr->isn_lnum;
                        iemsg("LOADOUTER depth more than scope levels");
!                       return FAIL;
                    }
                    tv = ((typval_T *)outer->out_stack->ga_data)
                                    + outer->out_frame_idx + STACK_FRAME_SIZE
--- 2276,2282 ----
                    {
                        SOURCING_LNUM = iptr->isn_lnum;
                        iemsg("LOADOUTER depth more than scope levels");
!                       goto theend;
                    }
                    tv = ((typval_T *)outer->out_stack->ga_data)
                                    + outer->out_frame_idx + STACK_FRAME_SIZE
***************
*** 2282,2288 ****
                    if (iptr->isn_type == ISN_LOADOUTER)
                    {
                        if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                           return FAIL;
                        copy_tv(tv, STACK_TV_BOT(0));
                        ++ectx->ec_stack.ga_len;
                    }
--- 2284,2290 ----
                    if (iptr->isn_type == ISN_LOADOUTER)
                    {
                        if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                           goto theend;
                        copy_tv(tv, STACK_TV_BOT(0));
                        ++ectx->ec_stack.ga_len;
                    }
***************
*** 2444,2450 ****
            case ISN_PUSHCHANNEL:
            case ISN_PUSHJOB:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   return FAIL;
                tv = STACK_TV_BOT(0);
                tv->v_lock = 0;
                ++ectx->ec_stack.ga_len;
--- 2446,2452 ----
            case ISN_PUSHCHANNEL:
            case ISN_PUSHJOB:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   goto theend;
                tv = STACK_TV_BOT(0);
                tv->v_lock = 0;
                ++ectx->ec_stack.ga_len;
***************
*** 2520,2526 ****
            // for the list header and the items
            case ISN_NEWLIST:
                if (exe_newlist(iptr->isn_arg.number, ectx) == FAIL)
!                   return FAIL;
                break;
  
            // create a dict from items on the stack
--- 2522,2528 ----
            // for the list header and the items
            case ISN_NEWLIST:
                if (exe_newlist(iptr->isn_arg.number, ectx) == FAIL)
!                   goto theend;
                break;
  
            // create a dict from items on the stack
***************
*** 2533,2539 ****
                    int         idx;
  
                    if (dict == NULL)
!                       return FAIL;
                    for (idx = 0; idx < count; ++idx)
                    {
                        // have already checked key type is VAR_STRING
--- 2535,2541 ----
                    int         idx;
  
                    if (dict == NULL)
!                       goto theend;
                    for (idx = 0; idx < count; ++idx)
                    {
                        // have already checked key type is VAR_STRING
***************
*** 2554,2560 ****
                        if (item == NULL)
                        {
                            dict_unref(dict);
!                           return FAIL;
                        }
                        item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1);
                        item->di_tv.v_lock = 0;
--- 2556,2562 ----
                        if (item == NULL)
                        {
                            dict_unref(dict);
!                           goto theend;
                        }
                        item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1);
                        item->di_tv.v_lock = 0;
***************
*** 2562,2575 ****
                        {
                            // can this ever happen?
                            dict_unref(dict);
!                           return FAIL;
                        }
                    }
  
                    if (count > 0)
                        ectx->ec_stack.ga_len -= 2 * count - 1;
                    else if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    else
                        ++ectx->ec_stack.ga_len;
                    tv = STACK_TV_BOT(-1);
--- 2564,2577 ----
                        {
                            // can this ever happen?
                            dict_unref(dict);
!                           goto theend;
                        }
                    }
  
                    if (count > 0)
                        ectx->ec_stack.ga_len -= 2 * count - 1;
                    else if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    else
                        ++ectx->ec_stack.ga_len;
                    tv = STACK_TV_BOT(-1);
***************
*** 2651,2657 ****
            // return from a :def function call
            case ISN_RETURN_ZERO:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   return FAIL;
                tv = STACK_TV_BOT(0);
                ++ectx->ec_stack.ga_len;
                tv->v_type = VAR_NUMBER;
--- 2653,2659 ----
            // return from a :def function call
            case ISN_RETURN_ZERO:
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   goto theend;
                tv = STACK_TV_BOT(0);
                ++ectx->ec_stack.ga_len;
                tv->v_type = VAR_NUMBER;
***************
*** 2690,2704 ****
                                               + iptr->isn_arg.funcref.fr_func;
  
                    if (pt == NULL)
!                       return FAIL;
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
                    {
                        vim_free(pt);
!                       return FAIL;
                    }
                    if (fill_partial_and_closure(pt, pt_dfunc->df_ufunc,
                                                                 ectx) == FAIL)
!                       return FAIL;
  
                    tv = STACK_TV_BOT(0);
                    ++ectx->ec_stack.ga_len;
--- 2692,2706 ----
                                               + iptr->isn_arg.funcref.fr_func;
  
                    if (pt == NULL)
!                       goto theend;
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
                    {
                        vim_free(pt);
!                       goto theend;
                    }
                    if (fill_partial_and_closure(pt, pt_dfunc->df_ufunc,
                                                                 ectx) == FAIL)
!                       goto theend;
  
                    tv = STACK_TV_BOT(0);
                    ++ectx->ec_stack.ga_len;
***************
*** 2715,2721 ****
  
                    if (copy_func(newfunc->nf_lambda, newfunc->nf_global,
                                                                 ectx) == FAIL)
!                       return FAIL;
                }
                break;
  
--- 2717,2723 ----
  
                    if (copy_func(newfunc->nf_lambda, newfunc->nf_global,
                                                                 ectx) == FAIL)
!                       goto theend;
                }
                break;
  
***************
*** 2788,2794 ****
                                   STACK_TV_VAR(iptr->isn_arg.forloop.for_idx);
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    if (ltv->v_type == VAR_LIST)
                    {
                        list_T *list = ltv->vval.v_list;
--- 2790,2796 ----
                                   STACK_TV_VAR(iptr->isn_arg.forloop.for_idx);
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    if (ltv->v_type == VAR_LIST)
                    {
                        list_T *list = ltv->vval.v_list;
***************
*** 2884,2890 ****
                    {
                        semsg(_(e_for_loop_on_str_not_supported),
                                                    vartype_name(ltv->v_type));
!                       return FAIL;
                    }
                }
                break;
--- 2886,2892 ----
                    {
                        semsg(_(e_for_loop_on_str_not_supported),
                                                    vartype_name(ltv->v_type));
!                       goto theend;
                    }
                }
                break;
***************
*** 2895,2901 ****
                    trycmd_T    *trycmd = NULL;
  
                    if (GA_GROW(&ectx->ec_trystack, 1) == FAIL)
!                       return FAIL;
                    trycmd = ((trycmd_T *)ectx->ec_trystack.ga_data)
                                                     + ectx->ec_trystack.ga_len;
                    ++ectx->ec_trystack.ga_len;
--- 2897,2903 ----
                    trycmd_T    *trycmd = NULL;
  
                    if (GA_GROW(&ectx->ec_trystack, 1) == FAIL)
!                       goto theend;
                    trycmd = ((trycmd_T *)ectx->ec_trystack.ga_data)
                                                     + ectx->ec_trystack.ga_len;
                    ++ectx->ec_trystack.ga_len;
***************
*** 2917,2926 ****
                {
                    SOURCING_LNUM = iptr->isn_lnum;
                    iemsg("Evaluating catch while current_exception is NULL");
!                   return FAIL;
                }
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   return FAIL;
                tv = STACK_TV_BOT(0);
                ++ectx->ec_stack.ga_len;
                tv->v_type = VAR_STRING;
--- 2919,2928 ----
                {
                    SOURCING_LNUM = iptr->isn_lnum;
                    iemsg("Evaluating catch while current_exception is NULL");
!                   goto theend;
                }
                if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                   goto theend;
                tv = STACK_TV_BOT(0);
                ++ectx->ec_stack.ga_len;
                tv->v_type = VAR_STRING;
***************
*** 2958,2964 ****
                    {
                        siemsg("TRYCONT: expected %d levels, found %d",
                                        trycont->tct_levels, trystack->ga_len);
!                       return FAIL;
                    }
                    // Make :endtry jump to any outer try block and the last
                    // :endtry inside the loop to the loop start.
--- 2960,2966 ----
                    {
                        siemsg("TRYCONT: expected %d levels, found %d",
                                        trycont->tct_levels, trystack->ga_len);
!                       goto theend;
                    }
                    // Make :endtry jump to any outer try block and the last
                    // :endtry inside the loop to the loop start.
***************
*** 3049,3055 ****
                        vim_free(tv->vval.v_string);
                        SOURCING_LNUM = iptr->isn_lnum;
                        emsg(_(e_throw_with_empty_string));
!                       return FAIL;
                    }
  
                    // Inside a "catch" we need to first discard the caught
--- 3051,3057 ----
                        vim_free(tv->vval.v_string);
                        SOURCING_LNUM = iptr->isn_lnum;
                        emsg(_(e_throw_with_empty_string));
!                       goto theend;
                    }
  
                    // Inside a "catch" we need to first discard the caught
***************
*** 3072,3078 ****
                                                                       == FAIL)
                    {
                        vim_free(tv->vval.v_string);
!                       return FAIL;
                    }
                    did_throw = TRUE;
                }
--- 3074,3080 ----
                                                                       == FAIL)
                    {
                        vim_free(tv->vval.v_string);
!                       goto theend;
                    }
                    did_throw = TRUE;
                }
***************
*** 3277,3283 ****
                        goto on_error;
                    }
                    if (list_append_tv(l, tv2) == FAIL)
!                       return FAIL;
                    clear_tv(tv2);
                    --ectx->ec_stack.ga_len;
                }
--- 3279,3285 ----
                        goto on_error;
                    }
                    if (list_append_tv(l, tv2) == FAIL)
!                       goto theend;
                    clear_tv(tv2);
                    --ectx->ec_stack.ga_len;
                }
***************
*** 3577,3583 ****
                    li = list_find(tv->vval.v_list, index);
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    ++ectx->ec_stack.ga_len;
                    copy_tv(&li->li_tv, STACK_TV_BOT(-1));
  
--- 3579,3585 ----
                    li = list_find(tv->vval.v_list, index);
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    ++ectx->ec_stack.ga_len;
                    copy_tv(&li->li_tv, STACK_TV_BOT(-1));
  
***************
*** 3810,3816 ****
                        goto on_error;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       return FAIL;
                    ++ectx->ec_stack.ga_len;
                    tv = STACK_TV_BOT(-1);
                    tv->v_type = VAR_NUMBER;
--- 3812,3818 ----
                        goto on_error;
  
                    if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
!                       goto theend;
                    ++ectx->ec_stack.ga_len;
                    tv = STACK_TV_BOT(-1);
                    tv->v_type = VAR_NUMBER;
***************
*** 3912,3918 ****
  
                    CHECK_LIST_MATERIALIZE(l);
                    if (GA_GROW(&ectx->ec_stack, count - 1) == FAIL)
!                       return FAIL;
                    ectx->ec_stack.ga_len += count - 1;
  
                    // Variable after semicolon gets a list with the remaining
--- 3914,3920 ----
  
                    CHECK_LIST_MATERIALIZE(l);
                    if (GA_GROW(&ectx->ec_stack, count - 1) == FAIL)
!                       goto theend;
                    ectx->ec_stack.ga_len += count - 1;
  
                    // Variable after semicolon gets a list with the remaining
***************
*** 3923,3929 ****
                                  list_alloc_with_items(l->lv_len - count + 1);
  
                        if (rem_list == NULL)
!                           return FAIL;
                        tv = STACK_TV_BOT(-count);
                        tv->vval.v_list = rem_list;
                        ++rem_list->lv_refcount;
--- 3925,3931 ----
                                  list_alloc_with_items(l->lv_len - count + 1);
  
                        if (rem_list == NULL)
!                           goto theend;
                        tv = STACK_TV_BOT(-count);
                        tv->vval.v_list = rem_list;
                        ++rem_list->lv_refcount;
***************
*** 4007,4013 ****
  
        if (func_return(ectx) == FAIL)
            // only fails when out of memory
!           return FAIL;
        continue;
  
  on_error:
--- 4009,4015 ----
  
        if (func_return(ectx) == FAIL)
            // only fails when out of memory
!           goto theend;
        continue;
  
  on_error:
***************
*** 4037,4047 ****
        // Jump here for an error that messes up the stack.
        // If we are not inside a try-catch started here, abort execution.
        if (trylevel <= ectx->ec_trylevel_at_start)
!           return FAIL;
      }
  
  done:
!     return OK;
  }
  
  /*
--- 4039,4052 ----
        // Jump here for an error that messes up the stack.
        // If we are not inside a try-catch started here, abort execution.
        if (trylevel <= ectx->ec_trylevel_at_start)
!           goto theend;
      }
  
  done:
!     ret = OK;
! theend:
!     ectx->ec_trylevel_at_start = save_trylevel_at_start;
!     return ret;
  }
  
  /*
*** ../vim-8.2.2867/src/testdir/test_vim9_builtin.vim   2021-05-16 
15:24:45.654704709 +0200
--- src/testdir/test_vim9_builtin.vim   2021-05-18 17:46:51.349331861 +0200
***************
*** 1014,1025 ****
          try
            searchpairpos('(', '', ')', 'nW', '[0]->map("")')
          catch
          endtry
        enddef
        Fail()
    END
!   CheckScriptFailure(lines, 'E15:')
  
    bwipe!
  enddef
  
--- 1014,1028 ----
          try
            searchpairpos('(', '', ')', 'nW', '[0]->map("")')
          catch
+           g:caught = 'yes'
          endtry
        enddef
        Fail()
    END
!   CheckScriptSuccess(lines)
!   assert_equal('yes', g:caught)
  
+   unlet g:caught
    bwipe!
  enddef
  
*** ../vim-8.2.2867/src/version.c       2021-05-18 15:32:07.857673075 +0200
--- src/version.c       2021-05-18 17:41:59.794642762 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2868,
  /**/

-- 
Back up my hard drive?  I can't find the reverse switch!

 /// 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/202105181550.14IFoUu94083261%40masaka.moolenaar.net.

Raspunde prin e-mail lui