diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-01-26 16:50:05 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-01-26 16:50:05 +0100 |
commit | 673660ab00d808d1e96e7181a60c5c8545c0ee75 (patch) | |
tree | f1640b455e435624fa045d972e7d27ee5b77dda1 | |
parent | 8a7d6542b33e5d2b352262305c3bfdb2d14e1cf8 (diff) | |
download | vim-git-673660ab00d808d1e96e7181a60c5c8545c0ee75.tar.gz |
patch 8.2.0150: cannot define python function when using :executev8.2.0150
Problem: Cannot define python function when using :execute. (Yasuhiro
Matsumoto)
Solution: Do not recognize "def" inside "function.
-rw-r--r-- | src/testdir/test_vim9_script.vim | 13 | ||||
-rw-r--r-- | src/userfunc.c | 5 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index ce1ab34d6..d6a78544b 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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,5 +357,16 @@ def Test_fixed_size_list() 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 diff --git a/src/userfunc.c b/src/userfunc.c index 808ed968a..ce776eeab 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -2667,8 +2667,11 @@ ex_function(exarg_T *eap) 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) || checkforcmd(&p, "def", 3)) + if (checkforcmd(&p, "function", 2) + || (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3))) { if (*p == '!') p = skipwhite(p + 1); diff --git a/src/version.c b/src/version.c index 3b4a9599e..159d55036 100644 --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 150, +/**/ 149, /**/ 148, |