Patch 8.2.0150
Problem: Cannot define python function when using :execute. (Yasuhiro
Matsumoto)
Solution: Do not recognize "def" inside "function.
Files: src/testdir/test_vim9_script.vim, src/userfunc.c
*** ../vim-8.2.0149/src/testdir/test_vim9_script.vim 2020-01-26 15:52:33.023833239 +0100
--- src/testdir/test_vim9_script.vim 2020-01-26 16:32:14.859967810 +0100
***************
*** 1,5 ****
--- 1,7 ----
" Test various aspects of the Vim9 script language.
+ source check.vim
+
" Check that "lines" inside ":def" results in an "error" message.
func CheckDefFailure(lines, error)
call writefile(['def! Func()'] + a:lines + ['enddef'], 'Xdef')
***************
*** 355,359 ****
--- 357,372 ----
call assert_equal([2, 99, 3, 4, 5], l)
enddef
+ " Test that inside :function a Python function can be defined, :def is not
+ " recognized.
+ func Test_function_python()
+ CheckFeature python3
+ let py = 'python3'
+ execute py "<< EOF"
+ def do_something():
+ return 1
+ EOF
+ endfunc
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.0149/src/userfunc.c 2020-01-26 15:52:33.027833222 +0100
--- src/userfunc.c 2020-01-26 16:32:16.527959143 +0100
***************
*** 2667,2674 ****
indent += 2;
// Check for defining a function inside this function.
c = *p;
! if (checkforcmd(&p, "function", 2) || checkforcmd(&p, "def", 3))
{
if (*p == '!')
p = skipwhite(p + 1);
--- 2667,2677 ----
indent += 2;
// Check for defining a function inside this function.
+ // Only recognize "def" inside "def", not inside "function",
+ // For backwards compatibility, see Test_function_python().
c = *p;
! if (checkforcmd(&p, "function", 2)
! || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3)))
{
if (*p == '!')
p = skipwhite(p + 1);
*** ../vim-8.2.0149/src/version.c 2020-01-26 15:52:33.027833222 +0100
--- src/version.c 2020-01-26 16:27:09.697613724 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 150,
/**/
--
Sometimes you can protect millions of dollars in your budget simply by buying
a bag of cookies, dropping it on the budget anylyst's desk, and saying
something deeply personal such as "How was your weekend, big guy?"
(Scott Adams - The Dilbert principle)
/// 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 ///