Patch 8.2.2164

3 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 19, 2020, 3:24:27 PM12/19/20
to vim...@googlegroups.com

Patch 8.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)
Files: src/userfunc.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.2163/src/userfunc.c 2020-12-18 19:49:52.349571840 +0100
--- src/userfunc.c 2020-12-19 21:22:03.274005459 +0100
***************
*** 2654,2661 ****
goto theend;
}

! // In Vim9 script a user function is script-local by default.
vim9script = ASCII_ISUPPER(*start) && in_vim9script();

/*
* Copy the function name to allocated memory.
--- 2654,2671 ----
goto theend;
}

! // 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.
*** ../vim-8.2.2163/src/testdir/test_vim9_script.vim 2020-12-19 16:30:39.443810119 +0100
--- src/testdir/test_vim9_script.vim 2020-12-19 21:20:15.834388860 +0100
***************
*** 2799,2804 ****
--- 2799,2814 ----
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
*** ../vim-8.2.2163/src/version.c 2020-12-19 17:55:50.810666202 +0100
--- src/version.c 2020-12-19 21:22:33.801897083 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2164,
/**/

--
Scientists decoded the first message from an alien civilization:
SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
STAR SYSTEMS. WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
MAXIMUM! IT REALLY WORKS!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages