Skip to content

Commit

Permalink
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
brammool committed Jan 19, 2022
1 parent 937610b commit f67c717
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4146,
/**/
4145,
/**/
Expand Down
21 changes: 15 additions & 6 deletions src/vim9expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f67c717

Please sign in to comment.