]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1017: Vim9: Patch 9.1.1013 causes a few problems v9.1.1017
authorYegappan Lakshmanan <yegappan@yahoo.com>
Wed, 15 Jan 2025 17:25:19 +0000 (18:25 +0100)
committerChristian Brabandt <cb@256bit.org>
Wed, 15 Jan 2025 17:25:19 +0000 (18:25 +0100)
Problem:  Vim9: Patch 9.1.1013 causes a few problems
Solution: Translate the function name only when it is a string
          (Yegappan Lakshmanan)

fixes: #16453
closes: #16450

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/evalfunc.c
src/testdir/test_functions.vim
src/testdir/test_vim9_func.vim
src/version.c

index 63142523c53d636ef6f3ad7b08942f62be488da0..71e3448ae39952b09eee5d33cafd7a245df89250 100644 (file)
@@ -3769,14 +3769,17 @@ f_call(typval_T *argvars, typval_T *rettv)
     if (func == NULL || *func == NUL)
        return;         // type error, empty name or null function
 
-    char_u     *p = func;
-    tofree = trans_function_name(&p, NULL, FALSE, TFN_INT|TFN_QUIET);
-    if (tofree == NULL)
+    if (argvars[0].v_type == VAR_STRING)
     {
-       emsg_funcname(e_unknown_function_str, func);
-       return;
+       char_u  *p = func;
+       tofree = trans_function_name(&p, NULL, FALSE, TFN_INT|TFN_QUIET);
+       if (tofree == NULL)
+       {
+           emsg_funcname(e_unknown_function_str, func);
+           return;
+       }
+       func = tofree;
     }
-    func = tofree;
 
     if (argvars[2].v_type != VAR_UNKNOWN)
     {
index 8b0af9101596ed4554ff664a0251177a34bb43eb..9fc954c08af2e3a4cb3766afec3558bb5d7ab139 100644 (file)
@@ -2990,6 +2990,8 @@ endfunc
 func Test_call()
   call assert_equal(3, call('len', [123]))
   call assert_equal(3, 'len'->call([123]))
+  call assert_equal(4, call({ x -> len(x) }, ['xxxx']))
+  call assert_equal(2, call(function('len'), ['xx']))
   call assert_fails("call call('len', 123)", 'E1211:')
   call assert_equal(0, call('', []))
   call assert_equal(0, call('len', test_null_list()))
index 38832e99d62a0c9b2e54ef1373d166df2282ce82..4e31f34d6a97b801a7cab3c37669deb0ac994031 100644 (file)
@@ -4729,6 +4729,9 @@ def Test_call_modified_import_func()
     export def Run()
       done = 0
       Setup()
+      call(Setup, [])
+      call("Setup", [])
+      call(() => Setup(), [])
       done += 1
     enddef
   END
@@ -4749,7 +4752,7 @@ def Test_call_modified_import_func()
 
     imp.Run()
 
-    assert_equal(1, setup)
+    assert_equal(4, setup)
     assert_equal(1, imp.done)
   END
   v9.CheckScriptSuccess(lines)
index 13ffc5d4e88154925b2838cedf0b0cb29036ce54..39c0aa64ef49b083b655355f0b11be2b9bcf09f8 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1017,
 /**/
     1016,
 /**/