comparison src/userfunc.c @ 20189:63cc54100ae4 v8.2.0650

patch 8.2.0650: Vim9: script function can be deleted Commit: https://github.com/vim/vim/commit/4c17ad94ecb0a0fb26d6fface2614bc5172dea18 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 27 22:47:51 2020 +0200 patch 8.2.0650: Vim9: script function can be deleted Problem: Vim9: script function can be deleted. Solution: Disallow deleting script function. Delete functions when sourcing a script again.
author Bram Moolenaar <Bram@vim.org>
date Mon, 27 Apr 2020 23:00:03 +0200
parents c21a1d91f78d
children cf13b26be258
comparison
equal deleted inserted replaced
20188:085eb4da46f4 20189:63cc54100ae4
23 #define FC_REMOVED 0x20 // function redefined while uf_refcount > 0 23 #define FC_REMOVED 0x20 // function redefined while uf_refcount > 0
24 #define FC_SANDBOX 0x40 // function defined in the sandbox 24 #define FC_SANDBOX 0x40 // function defined in the sandbox
25 #define FC_DEAD 0x80 // function kept only for reference to dfunc 25 #define FC_DEAD 0x80 // function kept only for reference to dfunc
26 #define FC_EXPORT 0x100 // "export def Func()" 26 #define FC_EXPORT 0x100 // "export def Func()"
27 #define FC_NOARGS 0x200 // no a: variables in lambda 27 #define FC_NOARGS 0x200 // no a: variables in lambda
28 #define FC_VIM9 0x400 // defined in vim9 script file
28 29
29 /* 30 /*
30 * All user-defined functions are found in this hashtable. 31 * All user-defined functions are found in this hashtable.
31 */ 32 */
32 static hashtab_T func_hashtab; 33 static hashtab_T func_hashtab;
708 return NULL; 709 return NULL;
709 } 710 }
710 711
711 /* 712 /*
712 * Find a function by name, return pointer to it in ufuncs. 713 * Find a function by name, return pointer to it in ufuncs.
714 * When "is_global" is true don't find script-local or imported functions.
713 * Return NULL for unknown function. 715 * Return NULL for unknown function.
714 */ 716 */
715 static ufunc_T * 717 static ufunc_T *
716 find_func_even_dead(char_u *name, cctx_T *cctx) 718 find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
717 { 719 {
718 hashitem_T *hi; 720 hashitem_T *hi;
719 ufunc_T *func; 721 ufunc_T *func;
720 imported_T *imported; 722 imported_T *imported;
721 723
722 if (in_vim9script()) 724 if (in_vim9script() && !is_global)
723 { 725 {
724 // Find script-local function before global one. 726 // Find script-local function before global one.
725 func = find_func_with_sid(name, current_sctx.sc_sid); 727 func = find_func_with_sid(name, current_sctx.sc_sid);
726 if (func != NULL) 728 if (func != NULL)
727 return func; 729 return func;
748 * Find a function by name, return pointer to it in ufuncs. 750 * Find a function by name, return pointer to it in ufuncs.
749 * "cctx" is passed in a :def function to find imported functions. 751 * "cctx" is passed in a :def function to find imported functions.
750 * Return NULL for unknown or dead function. 752 * Return NULL for unknown or dead function.
751 */ 753 */
752 ufunc_T * 754 ufunc_T *
753 find_func(char_u *name, cctx_T *cctx) 755 find_func(char_u *name, int is_global, cctx_T *cctx)
754 { 756 {
755 ufunc_T *fp = find_func_even_dead(name, cctx); 757 ufunc_T *fp = find_func_even_dead(name, is_global, cctx);
756 758
757 if (fp != NULL && (fp->uf_flags & FC_DEAD) == 0) 759 if (fp != NULL && (fp->uf_flags & FC_DEAD) == 0)
758 return fp; 760 return fp;
759 return NULL; 761 return NULL;
760 } 762 }
1571 1573
1572 funccall_T * 1574 funccall_T *
1573 get_current_funccal(void) 1575 get_current_funccal(void)
1574 { 1576 {
1575 return current_funccal; 1577 return current_funccal;
1578 }
1579
1580 /*
1581 * Mark all functions of script "sid" as deleted.
1582 */
1583 void
1584 delete_script_functions(int sid)
1585 {
1586 hashitem_T *hi;
1587 ufunc_T *fp;
1588 long_u todo;
1589 char buf[30];
1590 size_t len;
1591
1592 buf[0] = K_SPECIAL;
1593 buf[1] = KS_EXTRA;
1594 buf[2] = (int)KE_SNR;
1595 sprintf(buf + 3, "%d_", sid);
1596 len = STRLEN(buf);
1597
1598 todo = func_hashtab.ht_used;
1599 for (hi = func_hashtab.ht_array; todo > 0; ++hi)
1600 if (!HASHITEM_EMPTY(hi))
1601 {
1602 if (STRNCMP(fp->uf_name, buf, len) == 0)
1603 {
1604 fp = HI2UF(hi);
1605 fp->uf_flags |= FC_DEAD;
1606 func_clear(fp, TRUE);
1607 }
1608 --todo;
1609 }
1576 } 1610 }
1577 1611
1578 #if defined(EXITFREE) || defined(PROTO) 1612 #if defined(EXITFREE) || defined(PROTO)
1579 void 1613 void
1580 free_all_functions(void) 1614 free_all_functions(void)
1882 { 1916 {
1883 /* 1917 /*
1884 * User defined function. 1918 * User defined function.
1885 */ 1919 */
1886 if (fp == NULL) 1920 if (fp == NULL)
1887 fp = find_func(rfname, NULL); 1921 fp = find_func(rfname, FALSE, NULL);
1888 1922
1889 // Trigger FuncUndefined event, may load the function. 1923 // Trigger FuncUndefined event, may load the function.
1890 if (fp == NULL 1924 if (fp == NULL
1891 && apply_autocmds(EVENT_FUNCUNDEFINED, 1925 && apply_autocmds(EVENT_FUNCUNDEFINED,
1892 rfname, rfname, TRUE, NULL) 1926 rfname, rfname, TRUE, NULL)
1893 && !aborting()) 1927 && !aborting())
1894 { 1928 {
1895 // executed an autocommand, search for the function again 1929 // executed an autocommand, search for the function again
1896 fp = find_func(rfname, NULL); 1930 fp = find_func(rfname, FALSE, NULL);
1897 } 1931 }
1898 // Try loading a package. 1932 // Try loading a package.
1899 if (fp == NULL && script_autoload(rfname, TRUE) && !aborting()) 1933 if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
1900 { 1934 {
1901 // loaded a package, search for the function again 1935 // loaded a package, search for the function again
1902 fp = find_func(rfname, NULL); 1936 fp = find_func(rfname, FALSE, NULL);
1903 } 1937 }
1904 if (fp == NULL) 1938 if (fp == NULL)
1905 { 1939 {
1906 char_u *p = untrans_function_name(rfname); 1940 char_u *p = untrans_function_name(rfname);
1907 1941
1908 // If using Vim9 script try not local to the script. 1942 // If using Vim9 script try not local to the script.
1909 // TODO: should not do this if the name started with "s:". 1943 // TODO: should not do this if the name started with "s:".
1910 if (p != NULL) 1944 if (p != NULL)
1911 fp = find_func(p, NULL); 1945 fp = find_func(p, FALSE, NULL);
1912 } 1946 }
1913 1947
1914 if (fp != NULL && (fp->uf_flags & FC_DELETED)) 1948 if (fp != NULL && (fp->uf_flags & FC_DELETED))
1915 error = FCERR_DELETED; 1949 error = FCERR_DELETED;
1916 else if (fp != NULL) 1950 else if (fp != NULL)
2077 2111
2078 /* 2112 /*
2079 * Get a function name, translating "<SID>" and "<SNR>". 2113 * Get a function name, translating "<SID>" and "<SNR>".
2080 * Also handles a Funcref in a List or Dictionary. 2114 * Also handles a Funcref in a List or Dictionary.
2081 * Returns the function name in allocated memory, or NULL for failure. 2115 * Returns the function name in allocated memory, or NULL for failure.
2116 * Set "*is_global" to TRUE when the function must be global, unless
2117 * "is_global" is NULL.
2082 * flags: 2118 * flags:
2083 * TFN_INT: internal function name OK 2119 * TFN_INT: internal function name OK
2084 * TFN_QUIET: be quiet 2120 * TFN_QUIET: be quiet
2085 * TFN_NO_AUTOLOAD: do not use script autoloading 2121 * TFN_NO_AUTOLOAD: do not use script autoloading
2086 * TFN_NO_DEREF: do not dereference a Funcref 2122 * TFN_NO_DEREF: do not dereference a Funcref
2087 * Advances "pp" to just after the function name (if no error). 2123 * Advances "pp" to just after the function name (if no error).
2088 */ 2124 */
2089 char_u * 2125 char_u *
2090 trans_function_name( 2126 trans_function_name(
2091 char_u **pp, 2127 char_u **pp,
2128 int *is_global,
2092 int skip, // only find the end, don't evaluate 2129 int skip, // only find the end, don't evaluate
2093 int flags, 2130 int flags,
2094 funcdict_T *fdp, // return: info about dictionary used 2131 funcdict_T *fdp, // return: info about dictionary used
2095 partial_T **partial) // return: partial of a FuncRef 2132 partial_T **partial) // return: partial of a FuncRef
2096 { 2133 {
2237 } 2274 }
2238 else 2275 else
2239 { 2276 {
2240 // skip over "s:" and "g:" 2277 // skip over "s:" and "g:"
2241 if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':')) 2278 if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':'))
2279 {
2280 if (is_global != NULL && lv.ll_name[0] == 'g')
2281 *is_global = TRUE;
2242 lv.ll_name += 2; 2282 lv.ll_name += 2;
2283 }
2243 len = (int)(end - lv.ll_name); 2284 len = (int)(end - lv.ll_name);
2244 } 2285 }
2245 2286
2246 // In Vim9 script a user function is script-local by default. 2287 // In Vim9 script a user function is script-local by default.
2247 vim9script = ASCII_ISUPPER(*start) 2288 vim9script = ASCII_ISUPPER(*start)
2345 int j; 2386 int j;
2346 int c; 2387 int c;
2347 int saved_did_emsg; 2388 int saved_did_emsg;
2348 int saved_wait_return = need_wait_return; 2389 int saved_wait_return = need_wait_return;
2349 char_u *name = NULL; 2390 char_u *name = NULL;
2391 int is_global = FALSE;
2350 char_u *p; 2392 char_u *p;
2351 char_u *arg; 2393 char_u *arg;
2352 char_u *line_arg = NULL; 2394 char_u *line_arg = NULL;
2353 garray_T newargs; 2395 garray_T newargs;
2354 garray_T argtypes; 2396 garray_T argtypes;
2461 * "fudi.fd_di" set, "fudi.fd_newkey" == NULL 2503 * "fudi.fd_di" set, "fudi.fd_newkey" == NULL
2462 * s:func script-local function name 2504 * s:func script-local function name
2463 * g:func global function name, same as "func" 2505 * g:func global function name, same as "func"
2464 */ 2506 */
2465 p = eap->arg; 2507 p = eap->arg;
2466 name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL); 2508 name = trans_function_name(&p, &is_global, eap->skip,
2509 TFN_NO_AUTOLOAD, &fudi, NULL);
2467 paren = (vim_strchr(p, '(') != NULL); 2510 paren = (vim_strchr(p, '(') != NULL);
2468 if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) 2511 if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip)
2469 { 2512 {
2470 /* 2513 /*
2471 * Return on an invalid expression in braces, unless the expression 2514 * Return on an invalid expression in braces, unless the expression
2501 eap->nextcmd = check_nextcmd(p); 2544 eap->nextcmd = check_nextcmd(p);
2502 if (eap->nextcmd != NULL) 2545 if (eap->nextcmd != NULL)
2503 *p = NUL; 2546 *p = NUL;
2504 if (!eap->skip && !got_int) 2547 if (!eap->skip && !got_int)
2505 { 2548 {
2506 fp = find_func(name, NULL); 2549 fp = find_func(name, is_global, NULL);
2507 if (fp == NULL && ASCII_ISUPPER(*eap->arg)) 2550 if (fp == NULL && ASCII_ISUPPER(*eap->arg))
2508 { 2551 {
2509 char_u *up = untrans_function_name(name); 2552 char_u *up = untrans_function_name(name);
2510 2553
2511 // With Vim9 script the name was made script-local, if not 2554 // With Vim9 script the name was made script-local, if not
2512 // found try again with the original name. 2555 // found try again with the original name.
2513 if (up != NULL) 2556 if (up != NULL)
2514 fp = find_func(up, NULL); 2557 fp = find_func(up, FALSE, NULL);
2515 } 2558 }
2516 2559
2517 if (fp != NULL) 2560 if (fp != NULL)
2518 { 2561 {
2519 list_func_head(fp, TRUE); 2562 list_func_head(fp, TRUE);
2673 // need to skip the body to be able to find what follows. 2716 // need to skip the body to be able to find what follows.
2674 if (!eap->skip && !eap->forceit) 2717 if (!eap->skip && !eap->forceit)
2675 { 2718 {
2676 if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) 2719 if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL)
2677 emsg(_(e_funcdict)); 2720 emsg(_(e_funcdict));
2678 else if (name != NULL && find_func(name, NULL) != NULL) 2721 else if (name != NULL && find_func(name, is_global, NULL) != NULL)
2679 emsg_funcname(e_funcexts, name); 2722 emsg_funcname(e_funcexts, name);
2680 } 2723 }
2681 2724
2682 if (!eap->skip && did_emsg) 2725 if (!eap->skip && did_emsg)
2683 goto erret; 2726 goto erret;
2823 || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3))) 2866 || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3)))
2824 { 2867 {
2825 if (*p == '!') 2868 if (*p == '!')
2826 p = skipwhite(p + 1); 2869 p = skipwhite(p + 1);
2827 p += eval_fname_script(p); 2870 p += eval_fname_script(p);
2828 vim_free(trans_function_name(&p, TRUE, 0, NULL, NULL)); 2871 vim_free(trans_function_name(&p, NULL, TRUE, 0, NULL, NULL));
2829 if (*skipwhite(p) == '(') 2872 if (*skipwhite(p) == '(')
2830 { 2873 {
2831 if (nesting == MAX_FUNC_NESTING - 1) 2874 if (nesting == MAX_FUNC_NESTING - 1)
2832 emsg(_("E1058: function nesting too deep")); 2875 emsg(_("E1058: function nesting too deep"));
2833 else 2876 else
2961 emsg_funcname(N_("E707: Function name conflicts with variable: %s"), 3004 emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
2962 name); 3005 name);
2963 goto erret; 3006 goto erret;
2964 } 3007 }
2965 3008
2966 fp = find_func_even_dead(name, NULL); 3009 fp = find_func_even_dead(name, is_global, NULL);
2967 if (fp != NULL) 3010 if (fp != NULL)
2968 { 3011 {
2969 int dead = fp->uf_flags & FC_DEAD; 3012 int dead = fp->uf_flags & FC_DEAD;
2970 3013
2971 // Function can be replaced with "function!" and when sourcing the 3014 // Function can be replaced with "function!" and when sourcing the
3206 func_do_profile(fp); 3249 func_do_profile(fp);
3207 #endif 3250 #endif
3208 fp->uf_varargs = varargs; 3251 fp->uf_varargs = varargs;
3209 if (sandbox) 3252 if (sandbox)
3210 flags |= FC_SANDBOX; 3253 flags |= FC_SANDBOX;
3254 if (in_vim9script() && !ASCII_ISUPPER(*fp->uf_name))
3255 flags |= FC_VIM9;
3211 fp->uf_flags = flags; 3256 fp->uf_flags = flags;
3212 fp->uf_calls = 0; 3257 fp->uf_calls = 0;
3213 fp->uf_cleared = FALSE; 3258 fp->uf_cleared = FALSE;
3214 fp->uf_script_ctx = current_sctx; 3259 fp->uf_script_ctx = current_sctx;
3215 fp->uf_script_ctx.sc_lnum += sourcing_lnum_top; 3260 fp->uf_script_ctx.sc_lnum += sourcing_lnum_top;
3259 return 2; 3304 return 2;
3260 return 0; 3305 return 0;
3261 } 3306 }
3262 3307
3263 int 3308 int
3264 translated_function_exists(char_u *name) 3309 translated_function_exists(char_u *name, int is_global)
3265 { 3310 {
3266 if (builtin_function(name, -1)) 3311 if (builtin_function(name, -1))
3267 return has_internal_func(name); 3312 return has_internal_func(name);
3268 return find_func(name, NULL) != NULL; 3313 return find_func(name, is_global, NULL) != NULL;
3269 } 3314 }
3270 3315
3271 /* 3316 /*
3272 * Return TRUE when "ufunc" has old-style "..." varargs 3317 * Return TRUE when "ufunc" has old-style "..." varargs
3273 * or named varargs "...name: type". 3318 * or named varargs "...name: type".
3287 { 3332 {
3288 char_u *nm = name; 3333 char_u *nm = name;
3289 char_u *p; 3334 char_u *p;
3290 int n = FALSE; 3335 int n = FALSE;
3291 int flag; 3336 int flag;
3337 int is_global = FALSE;
3292 3338
3293 flag = TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD; 3339 flag = TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD;
3294 if (no_deref) 3340 if (no_deref)
3295 flag |= TFN_NO_DEREF; 3341 flag |= TFN_NO_DEREF;
3296 p = trans_function_name(&nm, FALSE, flag, NULL, NULL); 3342 p = trans_function_name(&nm, &is_global, FALSE, flag, NULL, NULL);
3297 nm = skipwhite(nm); 3343 nm = skipwhite(nm);
3298 3344
3299 // Only accept "funcname", "funcname ", "funcname (..." and 3345 // Only accept "funcname", "funcname ", "funcname (..." and
3300 // "funcname(...", not "funcname!...". 3346 // "funcname(...", not "funcname!...".
3301 if (p != NULL && (*nm == NUL || *nm == '(')) 3347 if (p != NULL && (*nm == NUL || *nm == '('))
3302 n = translated_function_exists(p); 3348 n = translated_function_exists(p, is_global);
3303 vim_free(p); 3349 vim_free(p);
3304 return n; 3350 return n;
3305 } 3351 }
3306 3352
3307 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) 3353 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
3308 char_u * 3354 char_u *
3309 get_expanded_name(char_u *name, int check) 3355 get_expanded_name(char_u *name, int check)
3310 { 3356 {
3311 char_u *nm = name; 3357 char_u *nm = name;
3312 char_u *p; 3358 char_u *p;
3313 3359 int is_global = FALSE;
3314 p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL, NULL); 3360
3315 3361 p = trans_function_name(&nm, &is_global, FALSE,
3316 if (p != NULL && *nm == NUL) 3362 TFN_INT|TFN_QUIET, NULL, NULL);
3317 if (!check || translated_function_exists(p)) 3363
3318 return p; 3364 if (p != NULL && *nm == NUL
3365 && (!check || translated_function_exists(p, is_global)))
3366 return p;
3319 3367
3320 vim_free(p); 3368 vim_free(p);
3321 return NULL; 3369 return NULL;
3322 } 3370 }
3323 #endif 3371 #endif
3374 { 3422 {
3375 ufunc_T *fp = NULL; 3423 ufunc_T *fp = NULL;
3376 char_u *p; 3424 char_u *p;
3377 char_u *name; 3425 char_u *name;
3378 funcdict_T fudi; 3426 funcdict_T fudi;
3427 int is_global = FALSE;
3379 3428
3380 p = eap->arg; 3429 p = eap->arg;
3381 name = trans_function_name(&p, eap->skip, 0, &fudi, NULL); 3430 name = trans_function_name(&p, &is_global, eap->skip, 0, &fudi, NULL);
3382 vim_free(fudi.fd_newkey); 3431 vim_free(fudi.fd_newkey);
3383 if (name == NULL) 3432 if (name == NULL)
3384 { 3433 {
3385 if (fudi.fd_dict != NULL && !eap->skip) 3434 if (fudi.fd_dict != NULL && !eap->skip)
3386 emsg(_(e_funcref)); 3435 emsg(_(e_funcref));
3395 eap->nextcmd = check_nextcmd(p); 3444 eap->nextcmd = check_nextcmd(p);
3396 if (eap->nextcmd != NULL) 3445 if (eap->nextcmd != NULL)
3397 *p = NUL; 3446 *p = NUL;
3398 3447
3399 if (!eap->skip) 3448 if (!eap->skip)
3400 fp = find_func(name, NULL); 3449 fp = find_func(name, is_global, NULL);
3401 vim_free(name); 3450 vim_free(name);
3402 3451
3403 if (!eap->skip) 3452 if (!eap->skip)
3404 { 3453 {
3405 if (fp == NULL) 3454 if (fp == NULL)
3409 return; 3458 return;
3410 } 3459 }
3411 if (fp->uf_calls > 0) 3460 if (fp->uf_calls > 0)
3412 { 3461 {
3413 semsg(_("E131: Cannot delete function %s: It is in use"), eap->arg); 3462 semsg(_("E131: Cannot delete function %s: It is in use"), eap->arg);
3463 return;
3464 }
3465 if (fp->uf_flags & FC_VIM9)
3466 {
3467 semsg(_("E1084: Cannot delete Vim9 script function %s"), eap->arg);
3414 return; 3468 return;
3415 } 3469 }
3416 3470
3417 if (fudi.fd_dict != NULL) 3471 if (fudi.fd_dict != NULL)
3418 { 3472 {
3450 { 3504 {
3451 ufunc_T *fp = NULL; 3505 ufunc_T *fp = NULL;
3452 3506
3453 if (name == NULL || !func_name_refcount(name)) 3507 if (name == NULL || !func_name_refcount(name))
3454 return; 3508 return;
3455 fp = find_func(name, NULL); 3509 fp = find_func(name, FALSE, NULL);
3456 if (fp == NULL && isdigit(*name)) 3510 if (fp == NULL && isdigit(*name))
3457 { 3511 {
3458 #ifdef EXITFREE 3512 #ifdef EXITFREE
3459 if (!entered_free_all_mem) 3513 if (!entered_free_all_mem)
3460 #endif 3514 #endif
3493 { 3547 {
3494 ufunc_T *fp; 3548 ufunc_T *fp;
3495 3549
3496 if (name == NULL || !func_name_refcount(name)) 3550 if (name == NULL || !func_name_refcount(name))
3497 return; 3551 return;
3498 fp = find_func(name, NULL); 3552 fp = find_func(name, FALSE, NULL);
3499 if (fp != NULL) 3553 if (fp != NULL)
3500 ++fp->uf_refcount; 3554 ++fp->uf_refcount;
3501 else if (isdigit(*name)) 3555 else if (isdigit(*name))
3502 // Only give an error for a numbered function. 3556 // Only give an error for a numbered function.
3503 // Fail silently, when named or lambda function isn't found. 3557 // Fail silently, when named or lambda function isn't found.
3609 clear_tv(&rettv); 3663 clear_tv(&rettv);
3610 --emsg_skip; 3664 --emsg_skip;
3611 return; 3665 return;
3612 } 3666 }
3613 3667
3614 tofree = trans_function_name(&arg, eap->skip, TFN_INT, &fudi, &partial); 3668 tofree = trans_function_name(&arg, NULL, eap->skip,
3669 TFN_INT, &fudi, &partial);
3615 if (fudi.fd_newkey != NULL) 3670 if (fudi.fd_newkey != NULL)
3616 { 3671 {
3617 // Still need to give an error message for missing key. 3672 // Still need to give an error message for missing key.
3618 semsg(_(e_dictkey), fudi.fd_newkey); 3673 semsg(_(e_dictkey), fudi.fd_newkey);
3619 vim_free(fudi.fd_newkey); 3674 vim_free(fudi.fd_newkey);
3967 { 4022 {
3968 fname = rettv->v_type == VAR_FUNC ? rettv->vval.v_string 4023 fname = rettv->v_type == VAR_FUNC ? rettv->vval.v_string
3969 : rettv->vval.v_partial->pt_name; 4024 : rettv->vval.v_partial->pt_name;
3970 // Translate "s:func" to the stored function name. 4025 // Translate "s:func" to the stored function name.
3971 fname = fname_trans_sid(fname, fname_buf, &tofree, &error); 4026 fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
3972 fp = find_func(fname, NULL); 4027 fp = find_func(fname, FALSE, NULL);
3973 vim_free(tofree); 4028 vim_free(tofree);
3974 } 4029 }
3975 4030
3976 if (fp != NULL && (fp->uf_flags & FC_DICT)) 4031 if (fp != NULL && (fp->uf_flags & FC_DICT))
3977 { 4032 {
4389 return FALSE; 4444 return FALSE;
4390 4445
4391 if (fp_in == NULL) 4446 if (fp_in == NULL)
4392 { 4447 {
4393 fname = fname_trans_sid(name, fname_buf, &tofree, &error); 4448 fname = fname_trans_sid(name, fname_buf, &tofree, &error);
4394 fp = find_func(fname, NULL); 4449 fp = find_func(fname, FALSE, NULL);
4395 } 4450 }
4396 if (fp != NULL) 4451 if (fp != NULL)
4397 { 4452 {
4398 for (fc = fp->uf_scoped; fc != NULL; fc = fc->func->uf_scoped) 4453 for (fc = fp->uf_scoped; fc != NULL; fc = fc->func->uf_scoped)
4399 abort = abort || set_ref_in_funccal(fc, copyID); 4454 abort = abort || set_ref_in_funccal(fc, copyID);