diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-19 21:23:42 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-19 21:23:42 +0100 |
commit | 17f700ac8b55f27ddb519ecaa8acaa43fc1ae60a (patch) | |
tree | 52529a79f2905eef3dc44ba94ec076360c84d166 /src | |
parent | 13656f02e457fb68cd7e72412fc24ccac02fb06e (diff) | |
download | vim-git-17f700ac8b55f27ddb519ecaa8acaa43fc1ae60a.tar.gz |
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased scriptv8.2.2164
Problem: Vim9: autoload function doesn't work in script that starts with
an upper case letter.
Solution: Check for the autoload character. (closes #7502)
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_vim9_script.vim | 10 | ||||
-rw-r--r-- | src/userfunc.c | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 5949acbc6..47ea43d3f 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -2799,6 +2799,16 @@ def Test_vim9_autoload() g:some#other = 'other' assert_equal('other', g:some#other) + # upper case script name works + lines =<< trim END + vim9script + def Other#getOther(): string + return 'other' + enddef + END + writefile(lines, 'Xdir/autoload/Other.vim') + assert_equal('other', g:Other#getOther()) + delete('Xdir', 'rf') &rtp = save_rtp enddef diff --git a/src/userfunc.c b/src/userfunc.c index 50088e638..31c7af3e7 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -2654,8 +2654,18 @@ trans_function_name( goto theend; } - // In Vim9 script a user function is script-local by default. + // In Vim9 script a user function is script-local by default, unless it + // starts with a lower case character: dict.func(). vim9script = ASCII_ISUPPER(*start) && in_vim9script(); + if (vim9script) + { + char_u *p; + + // SomeScript#func() is a global function. + for (p = start; *p != NUL && *p != '('; ++p) + if (*p == AUTOLOAD_CHAR) + vim9script = FALSE; + } /* * Copy the function name to allocated memory. diff --git a/src/version.c b/src/version.c index 8f2c50a9e..a97037d51 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 */ /**/ + 2164, +/**/ 2163, /**/ 2162, |