summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKota Kato <github@kat0h.com>2022-08-16 16:09:59 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-16 16:09:59 +0100
commit948a3894d98f5e2a6e7fc57189fe9c2a5919eebf (patch)
tree12c30f33547c5474f5de4369907fb037b41428bb /src
parente98c88c44c308edaea5994b8ad4363e65030968c (diff)
patch 9.0.0219: cannot make a funcref with "s:func" in a def functionv9.0.0219
Problem: Cannot make a funcref with "s:func" in a def function in legacy script. Solution: Allow for using a lower case function name after "s:". (Kota Kato, closes #10926)
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_vim9_func.vim39
-rw-r--r--src/userfunc.c3
-rw-r--r--src/version.c2
-rw-r--r--src/vim9expr.c5
4 files changed, 45 insertions, 4 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index d67dd55b6e..5c7545784f 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1957,6 +1957,45 @@ def Test_call_funcref()
g:listarg->assert_equal([1, 2, 3])
END
v9.CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ function s:func(num)
+ return a:num * 2
+ endfunction
+
+ def s:CallFuncref()
+ var Funcref = function('s:func')
+ Funcref(3)->assert_equal(6)
+ enddef
+ call s:CallFuncref()
+ END
+ v9.CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ function s:func(num)
+ return a:num * 2
+ endfunction
+
+ def s:CallFuncref()
+ var Funcref = function(s:func)
+ Funcref(3)->assert_equal(6)
+ enddef
+ call s:CallFuncref()
+ END
+ v9.CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ function s:func(num)
+ return a:num * 2
+ endfunction
+
+ def s:CallFuncref()
+ var Funcref = s:func
+ Funcref(3)->assert_equal(6)
+ enddef
+ call s:CallFuncref()
+ END
+ v9.CheckScriptSuccess(lines)
enddef
let SomeFunc = function('len')
diff --git a/src/userfunc.c b/src/userfunc.c
index ae3e20202b..f612160fc8 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -3995,7 +3995,8 @@ trans_function_name(
{
if (!vim9_local)
{
- if (vim9script && lead == 2 && !ASCII_ISUPPER(*lv.ll_name))
+ if (vim9script && lead == 2 && !ASCII_ISUPPER(*lv.ll_name)
+ && current_script_is_vim9())
{
semsg(_(e_function_name_must_start_with_capital_str), start);
goto theend;
diff --git a/src/version.c b/src/version.c
index 5d9f9f77d0..3aff052a75 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 219,
+/**/
218,
/**/
217,
diff --git a/src/vim9expr.c b/src/vim9expr.c
index b2bb405f6f..8cd095c1a7 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -8,7 +8,7 @@
*/
/*
- * vim9cmds.c: Dealing with compiled function expressions
+ * vim9expr.c: Dealing with compiled function expressions
*/
#define USING_FLOAT_STUFF
@@ -451,8 +451,7 @@ compile_load(
vim_free(name);
return FAIL;
}
- if (is_expr && ASCII_ISUPPER(*name)
- && find_func(name, FALSE) != NULL)
+ if (is_expr && find_func(name, FALSE) != NULL)
res = generate_funcref(cctx, name, FALSE);
else
res = compile_load_scriptvar(cctx, name,