]> granicus.if.org Git - vim/commitdiff
patch 8.2.4146: Vim9: shadowed function can be used in compiled function v8.2.4146
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Jan 2022 17:23:05 +0000 (17:23 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Jan 2022 17:23:05 +0000 (17:23 +0000)
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)

src/version.c
src/vim9expr.c

index 1906fc4aaf912bd9f0fddad79e491f2d490c9ac1..6babbdda6558dd12ab84acf147e6e6df8b804354 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4146,
 /**/
     4145,
 /**/
index 72bfc01e516550e47ca0a351ca0b68a734ee49bd..7cc30780785e74a7ce52be5a988a153f54c08e4b 100644 (file)
@@ -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()