Mercurial > vim
comparison src/vim9expr.c @ 27235:6b80d4acac8e v8.2.4146
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
Commit: https://github.com/vim/vim/commit/f67c717e34e5553ab1c3b02b1861274cbcb78935
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 19 17:23:05 2022 +0000
patch 8.2.4146: Vim9: shadowed function can be used in compiled function
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 19 Jan 2022 18:30:07 +0100 |
parents | facb54d20a50 |
children | 8a097fc07aa4 |
comparison
equal
deleted
inserted
replaced
27234:01767caa86b2 | 27235:6b80d4acac8e |
---|---|
666 int error = FCERR_NONE; | 666 int error = FCERR_NONE; |
667 ufunc_T *ufunc = NULL; | 667 ufunc_T *ufunc = NULL; |
668 int res = FAIL; | 668 int res = FAIL; |
669 int is_autoload; | 669 int is_autoload; |
670 int is_searchpair; | 670 int is_searchpair; |
671 imported_T *import; | |
672 | |
673 if (varlen >= sizeof(namebuf)) | |
674 { | |
675 semsg(_(e_name_too_long_str), name); | |
676 return FAIL; | |
677 } | |
678 vim_strncpy(namebuf, *arg, varlen); | |
679 | |
680 import = find_imported(name, varlen, FALSE, cctx); | |
681 if (import != NULL) | |
682 { | |
683 semsg(_(e_cannot_use_str_itself_it_is_imported), namebuf); | |
684 return FAIL; | |
685 } | |
671 | 686 |
672 // We can evaluate "has('name')" at compile time. | 687 // We can evaluate "has('name')" at compile time. |
673 // We always evaluate "exists_compiled()" at compile time. | 688 // We always evaluate "exists_compiled()" at compile time. |
674 if ((varlen == 3 && STRNCMP(*arg, "has", 3) == 0) | 689 if ((varlen == 3 && STRNCMP(*arg, "has", 3) == 0) |
675 || (varlen == 15 && STRNCMP(*arg, "exists_compiled", 6) == 0)) | 690 || (varlen == 15 && STRNCMP(*arg, "exists_compiled", 6) == 0)) |
711 } | 726 } |
712 | 727 |
713 if (generate_ppconst(cctx, ppconst) == FAIL) | 728 if (generate_ppconst(cctx, ppconst) == FAIL) |
714 return FAIL; | 729 return FAIL; |
715 | 730 |
716 if (varlen >= sizeof(namebuf)) | |
717 { | |
718 semsg(_(e_name_too_long_str), name); | |
719 return FAIL; | |
720 } | |
721 vim_strncpy(namebuf, *arg, varlen); | |
722 name = fname_trans_sid(namebuf, fname_buf, &tofree, &error); | 731 name = fname_trans_sid(namebuf, fname_buf, &tofree, &error); |
723 | 732 |
724 // We handle the "skip" argument of searchpair() and searchpairpos() | 733 // We handle the "skip" argument of searchpair() and searchpairpos() |
725 // differently. | 734 // differently. |
726 is_searchpair = (varlen == 6 && STRNCMP(*arg, "search", 6) == 0) | 735 is_searchpair = (varlen == 6 && STRNCMP(*arg, "search", 6) == 0) |