Mercurial > vim
comparison src/userfunc.c @ 23237:033b2a97d59b v8.2.2164
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Commit: https://github.com/vim/vim/commit/17f700ac8b55f27ddb519ecaa8acaa43fc1ae60a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 19 21:23:42 2020 +0100
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Problem: Vim9: autoload function doesn't work in script that starts with
an upper case letter.
Solution: Check for the autoload character. (closes #7502)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Dec 2020 21:30:03 +0100 |
parents | b545334ae654 |
children | 43532077b5ff |
comparison
equal
deleted
inserted
replaced
23236:1726af77ad66 | 23237:033b2a97d59b |
---|---|
2652 if (!skip) | 2652 if (!skip) |
2653 emsg(_(e_function_name)); | 2653 emsg(_(e_function_name)); |
2654 goto theend; | 2654 goto theend; |
2655 } | 2655 } |
2656 | 2656 |
2657 // In Vim9 script a user function is script-local by default. | 2657 // In Vim9 script a user function is script-local by default, unless it |
2658 // starts with a lower case character: dict.func(). | |
2658 vim9script = ASCII_ISUPPER(*start) && in_vim9script(); | 2659 vim9script = ASCII_ISUPPER(*start) && in_vim9script(); |
2660 if (vim9script) | |
2661 { | |
2662 char_u *p; | |
2663 | |
2664 // SomeScript#func() is a global function. | |
2665 for (p = start; *p != NUL && *p != '('; ++p) | |
2666 if (*p == AUTOLOAD_CHAR) | |
2667 vim9script = FALSE; | |
2668 } | |
2659 | 2669 |
2660 /* | 2670 /* |
2661 * Copy the function name to allocated memory. | 2671 * Copy the function name to allocated memory. |
2662 * Accept <SID>name() inside a script, translate into <SNR>123_name(). | 2672 * Accept <SID>name() inside a script, translate into <SNR>123_name(). |
2663 * Accept <SNR>123_name() outside a script. | 2673 * Accept <SNR>123_name() outside a script. |