• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisiond19adfd545e26c20c28320cf471745777fe1207c (tree)
Time2022-08-17 00:15:03
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 9.0.0219: cannot make a funcref with "s:func" in a def function

Commit: https://github.com/vim/vim/commit/948a3894d98f5e2a6e7fc57189fe9c2a5919eebf
Author: Kota Kato <github@kat0h.com>
Date: Tue Aug 16 16:09:59 2022 +0100

patch 9.0.0219: cannot make a funcref with "s:func" in a def function
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)

Change Summary

Incremental Difference

diff -r 7e306219b233 -r d19adfd545e2 src/testdir/test_vim9_func.vim
--- a/src/testdir/test_vim9_func.vim Tue Aug 16 16:00:08 2022 +0200
+++ b/src/testdir/test_vim9_func.vim Tue Aug 16 17:15:03 2022 +0200
@@ -1957,6 +1957,45 @@
19571957 g:listarg->assert_equal([1, 2, 3])
19581958 END
19591959 v9.CheckScriptSuccess(lines)
1960+
1961+ lines =<< trim END
1962+ function s:func(num)
1963+ return a:num * 2
1964+ endfunction
1965+
1966+ def s:CallFuncref()
1967+ var Funcref = function('s:func')
1968+ Funcref(3)->assert_equal(6)
1969+ enddef
1970+ call s:CallFuncref()
1971+ END
1972+ v9.CheckScriptSuccess(lines)
1973+
1974+ lines =<< trim END
1975+ function s:func(num)
1976+ return a:num * 2
1977+ endfunction
1978+
1979+ def s:CallFuncref()
1980+ var Funcref = function(s:func)
1981+ Funcref(3)->assert_equal(6)
1982+ enddef
1983+ call s:CallFuncref()
1984+ END
1985+ v9.CheckScriptSuccess(lines)
1986+
1987+ lines =<< trim END
1988+ function s:func(num)
1989+ return a:num * 2
1990+ endfunction
1991+
1992+ def s:CallFuncref()
1993+ var Funcref = s:func
1994+ Funcref(3)->assert_equal(6)
1995+ enddef
1996+ call s:CallFuncref()
1997+ END
1998+ v9.CheckScriptSuccess(lines)
19601999 enddef
19612000
19622001 let SomeFunc = function('len')
diff -r 7e306219b233 -r d19adfd545e2 src/userfunc.c
--- a/src/userfunc.c Tue Aug 16 16:00:08 2022 +0200
+++ b/src/userfunc.c Tue Aug 16 17:15:03 2022 +0200
@@ -3995,7 +3995,8 @@
39953995 {
39963996 if (!vim9_local)
39973997 {
3998- if (vim9script && lead == 2 && !ASCII_ISUPPER(*lv.ll_name))
3998+ if (vim9script && lead == 2 && !ASCII_ISUPPER(*lv.ll_name)
3999+ && current_script_is_vim9())
39994000 {
40004001 semsg(_(e_function_name_must_start_with_capital_str), start);
40014002 goto theend;
diff -r 7e306219b233 -r d19adfd545e2 src/version.c
--- a/src/version.c Tue Aug 16 16:00:08 2022 +0200
+++ b/src/version.c Tue Aug 16 17:15:03 2022 +0200
@@ -736,6 +736,8 @@
736736 static int included_patches[] =
737737 { /* Add new patch number below this line */
738738 /**/
739+ 219,
740+/**/
739741 218,
740742 /**/
741743 217,
diff -r 7e306219b233 -r d19adfd545e2 src/vim9expr.c
--- a/src/vim9expr.c Tue Aug 16 16:00:08 2022 +0200
+++ b/src/vim9expr.c Tue Aug 16 17:15:03 2022 +0200
@@ -8,7 +8,7 @@
88 */
99
1010 /*
11- * vim9cmds.c: Dealing with compiled function expressions
11+ * vim9expr.c: Dealing with compiled function expressions
1212 */
1313
1414 #define USING_FLOAT_STUFF
@@ -451,8 +451,7 @@
451451 vim_free(name);
452452 return FAIL;
453453 }
454- if (is_expr && ASCII_ISUPPER(*name)
455- && find_func(name, FALSE) != NULL)
454+ if (is_expr && find_func(name, FALSE) != NULL)
456455 res = generate_funcref(cctx, name, FALSE);
457456 else
458457 res = compile_load_scriptvar(cctx, name,
Show on old repository browser