comparison src/userfunc.c @ 15008:67e3103d6e18 v8.1.0515

patch 8.1.0515: reloading a script gives errors for existing functions commit https://github.com/vim/vim/commit/ded5f1bed7ff2d138b3ee0f9610d17290b62692d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 10 17:33:29 2018 +0100 patch 8.1.0515: reloading a script gives errors for existing functions Problem: Reloading a script gives errors for existing functions. Solution: Allow redefining a function once when reloading a script.
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Nov 2018 17:45:06 +0100
parents 32787e326de2
children 9df130fd5e0d
comparison
equal deleted inserted replaced
15007:d04499070024 15008:67e3103d6e18
2328 } 2328 }
2329 2329
2330 fp = find_func(name); 2330 fp = find_func(name);
2331 if (fp != NULL) 2331 if (fp != NULL)
2332 { 2332 {
2333 if (!eap->forceit) 2333 // Function can be replaced with "function!" and when sourcing the
2334 // same script again, but only once.
2335 if (!eap->forceit
2336 && (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
2337 || fp->uf_script_ctx.sc_seq == current_sctx.sc_seq))
2334 { 2338 {
2335 emsg_funcname(e_funcexts, name); 2339 emsg_funcname(e_funcexts, name);
2336 goto erret; 2340 goto erret;
2337 } 2341 }
2338 if (fp->uf_calls > 0) 2342 if (fp->uf_calls > 0)
2339 { 2343 {
2340 emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"), 2344 emsg_funcname(
2345 N_("E127: Cannot redefine function %s: It is in use"),
2341 name); 2346 name);
2342 goto erret; 2347 goto erret;
2343 } 2348 }
2344 if (fp->uf_refcount > 1) 2349 if (fp->uf_refcount > 1)
2345 { 2350 {