comparison src/vim9compile.c @ 21604:d9c45474cac1 v8.2.1352

patch 8.2.1352: Vim9: no error for shadowing a script-local function Commit: https://github.com/vim/vim/commit/ad486a0f0dd194826fdb733516bf0f35382c9dd7 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 1 23:22:18 2020 +0200 patch 8.2.1352: Vim9: no error for shadowing a script-local function Problem: Vim9: no error for shadowing a script-local function by a nested function. Solution: Check for script-local function. (closes #6586)
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Aug 2020 23:30:03 +0200
parents 7028f45bf0ea
children 586241ee8096
comparison
equal deleted inserted replaced
21603:c6c1c4a5e4e0 21604:d9c45474cac1
289 * Return FAIL and give an error if it defined. 289 * Return FAIL and give an error if it defined.
290 */ 290 */
291 int 291 int
292 check_defined(char_u *p, size_t len, cctx_T *cctx) 292 check_defined(char_u *p, size_t len, cctx_T *cctx)
293 { 293 {
294 int c = p[len];
295
296 p[len] = NUL;
294 if (lookup_script(p, len) == OK 297 if (lookup_script(p, len) == OK
295 || (cctx != NULL 298 || (cctx != NULL
296 && (lookup_local(p, len, cctx) != NULL 299 && (lookup_local(p, len, cctx) != NULL
297 || lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK)) 300 || lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK))
298 || find_imported(p, len, cctx) != NULL) 301 || find_imported(p, len, cctx) != NULL
299 { 302 || find_func_even_dead(p, FALSE, cctx) != NULL)
303 {
304 p[len] = c;
300 semsg(_(e_already_defined), p); 305 semsg(_(e_already_defined), p);
301 return FAIL; 306 return FAIL;
302 } 307 }
308 p[len] = c;
303 return OK; 309 return OK;
304 } 310 }
305 311
306 /* 312 /*
307 * Allocate memory for a type_T and add the pointer to type_gap, so that it can 313 * Allocate memory for a type_T and add the pointer to type_gap, so that it can