diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-19 17:23:05 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-19 17:23:05 +0000 |
commit | f67c717e34e5553ab1c3b02b1861274cbcb78935 (patch) | |
tree | 6c85b22a9235a7a80d2ea5c2e86a8d9d478c4e1c | |
parent | 937610bc9f9c827e3e25fed32661fcbf3f994e10 (diff) | |
download | vim-git-f67c717e34e5553ab1c3b02b1861274cbcb78935.tar.gz |
patch 8.2.4146: Vim9: shadowed function can be used in compiled functionv8.2.4146
Problem: Vim9: shadowed function can be used in compiled function but not
at script level.
Solution: Also give an error in a compiled function. (closes #9563)
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9expr.c | 21 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/version.c b/src/version.c index 1906fc4aa..6babbdda6 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4146, +/**/ 4145, /**/ 4144, diff --git a/src/vim9expr.c b/src/vim9expr.c index 72bfc01e5..7cc307807 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -668,6 +668,21 @@ compile_call( int res = FAIL; int is_autoload; int is_searchpair; + imported_T *import; + + if (varlen >= sizeof(namebuf)) + { + semsg(_(e_name_too_long_str), name); + return FAIL; + } + vim_strncpy(namebuf, *arg, varlen); + + import = find_imported(name, varlen, FALSE, cctx); + if (import != NULL) + { + semsg(_(e_cannot_use_str_itself_it_is_imported), namebuf); + return FAIL; + } // We can evaluate "has('name')" at compile time. // We always evaluate "exists_compiled()" at compile time. @@ -713,12 +728,6 @@ compile_call( if (generate_ppconst(cctx, ppconst) == FAIL) return FAIL; - if (varlen >= sizeof(namebuf)) - { - semsg(_(e_name_too_long_str), name); - return FAIL; - } - vim_strncpy(namebuf, *arg, varlen); name = fname_trans_sid(namebuf, fname_buf, &tofree, &error); // We handle the "skip" argument of searchpair() and searchpairpos() |