Mercurial > vim
comparison src/evalvars.c @ 24049:fc4c2beea99a v8.2.2566
patch 8.2.2566: Vim9: Function name is not recognized
Commit: https://github.com/vim/vim/commit/2e2d758902dc08a0e383fe6b198e11dd14f1bdf8
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 3 21:22:41 2021 +0100
patch 8.2.2566: Vim9: Function name is not recognized
Problem: Vim9: Function name is not recognized.
Solution: Change lookup_scriptvar() to also find function names.
(closes #7770)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 03 Mar 2021 21:30:03 +0100 |
parents | 9fcd71d0db89 |
children | da8347e453b4 |
comparison
equal
deleted
inserted
replaced
24048:66a3e54d87c8 | 24049:fc4c2beea99a |
---|---|
2786 return &SCRIPT_VARS(sid); | 2786 return &SCRIPT_VARS(sid); |
2787 return NULL; | 2787 return NULL; |
2788 } | 2788 } |
2789 | 2789 |
2790 /* | 2790 /* |
2791 * Look for "name[len]" in script-local variables. | 2791 * Look for "name[len]" in script-local variables and functions. |
2792 * Return OK when found, FAIL when not found. | 2792 * Return OK when found, FAIL when not found. |
2793 */ | 2793 */ |
2794 int | 2794 int |
2795 lookup_scriptvar( | 2795 lookup_scriptitem( |
2796 char_u *name, | 2796 char_u *name, |
2797 size_t len, | 2797 size_t len, |
2798 cctx_T *dummy UNUSED) | 2798 cctx_T *dummy UNUSED) |
2799 { | 2799 { |
2800 hashtab_T *ht = get_script_local_ht(); | 2800 hashtab_T *ht = get_script_local_ht(); |
2801 char_u buffer[30]; | 2801 char_u buffer[30]; |
2802 char_u *p; | 2802 char_u *p; |
2803 int res; | 2803 int res; |
2804 hashitem_T *hi; | 2804 hashitem_T *hi; |
2805 int is_global = FALSE; | |
2806 char_u *fname = name; | |
2805 | 2807 |
2806 if (ht == NULL) | 2808 if (ht == NULL) |
2807 return FAIL; | 2809 return FAIL; |
2808 if (len < sizeof(buffer) - 1) | 2810 if (len < sizeof(buffer) - 1) |
2809 { | 2811 { |
2822 res = HASHITEM_EMPTY(hi) ? FAIL : OK; | 2824 res = HASHITEM_EMPTY(hi) ? FAIL : OK; |
2823 | 2825 |
2824 // if not script-local, then perhaps imported | 2826 // if not script-local, then perhaps imported |
2825 if (res == FAIL && find_imported(p, 0, NULL) != NULL) | 2827 if (res == FAIL && find_imported(p, 0, NULL) != NULL) |
2826 res = OK; | 2828 res = OK; |
2827 | |
2828 if (p != buffer) | 2829 if (p != buffer) |
2829 vim_free(p); | 2830 vim_free(p); |
2831 | |
2832 if (res != OK) | |
2833 { | |
2834 // Find a function, so that a following "->" works. Skip "g:" before a | |
2835 // function name. | |
2836 // Do not check for an internal function, since it might also be a | |
2837 // valid command, such as ":split" versuse "split()". | |
2838 if (name[0] == 'g' && name[1] == ':') | |
2839 { | |
2840 is_global = TRUE; | |
2841 fname = name + 2; | |
2842 } | |
2843 if (find_func(fname, is_global, NULL) != NULL) | |
2844 res = OK; | |
2845 } | |
2846 | |
2830 return res; | 2847 return res; |
2831 } | 2848 } |
2832 | 2849 |
2833 /* | 2850 /* |
2834 * Find the hashtab used for a variable name. | 2851 * Find the hashtab used for a variable name. |