changeset 26600:6fed1f1bc282 v8.2.3829

patch 8.2.3829: no error when setting a func option to script-local function Commit: https://github.com/vim/vim/commit/94c785d235dccacf6cdf38c5903115b61ca8a981 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 16 19:45:47 2021 +0000 patch 8.2.3829: no error when setting a func option to script-local function Problem: No error when setting a func option to a script-local function. Solution: Give an error if the name starts with "s:". (closes https://github.com/vim/vim/issues/9358)
author Bram Moolenaar <Bram@vim.org>
date Thu, 16 Dec 2021 21:00:03 +0100
parents 0ab9ea26db5f
children dd5a2a697523
files src/option.c src/testdir/dumps/Test_set_tagfunc_on_cmdline.dump src/testdir/test_tagfunc.vim src/version.c
diffstat 4 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/option.c
+++ b/src/option.c
@@ -7199,6 +7199,9 @@ option_set_callback_func(char_u *optval 
 	return OK;
     }
 
+    if (STRNCMP(optval, "s:", 2) == 0 && !SCRIPT_ID_VALID(current_sctx.sc_sid))
+	return FAIL;
+
     if (*optval == '{' || (in_vim9script() && *optval == '(')
 	    || (STRNCMP(optval, "function(", 9) == 0)
 	    || (STRNCMP(optval, "funcref(", 8) == 0))
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_set_tagfunc_on_cmdline.dump
@@ -0,0 +1,6 @@
+| +0&#ffffff0@74
+@75
+@75
+|E+0#ffffff16#e000002|r@1|o|r| |d|e|t|e|c|t|e|d| |w|h|i|l|e| |p|r|o|c|e|s@1|i|n|g| |c|o|m@1|a|n|d| |l|i|n|e|:| +0#0000000#ffffff0@29
+|E+0#ffffff16#e000002|4|7|4|:| |I|n|v|a|l|i|d| |a|r|g|u|m|e|n|t|:| |t|a|g|f|u|n|c|=|s|:|F|u|n|c| +0#0000000#ffffff0@36
+|P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o| |c|o|n|t|i|n|u|e> +0#0000000&@35
--- a/src/testdir/test_tagfunc.vim
+++ b/src/testdir/test_tagfunc.vim
@@ -1,6 +1,8 @@
 " Test 'tagfunc'
 
 source vim9.vim
+source check.vim
+source screendump.vim
 
 func TagFunc(pat, flag, info)
   let g:tagfunc_args = [a:pat, a:flag, a:info]
@@ -342,4 +344,13 @@ func Test_tagfunc_callback()
   %bw!
 endfunc
 
+func Test_set_tagfunc_on_cmdline()
+  CheckScreendump
+
+  let buf = RunVimInTerminal(' +"set tagfunc=s:Func"', #{rows: 6, wait_for_ruler: 0})
+  call VerifyScreenDump(buf, 'Test_set_tagfunc_on_cmdline', {})
+  call StopVimInTerminal(buf)
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3829,
+/**/
     3828,
 /**/
     3827,