]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1531: confusing error with nested legacy function v9.1.1531
authorHirohito Higashi <h.east.727@gmail.com>
Tue, 8 Jul 2025 21:07:21 +0000 (23:07 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 8 Jul 2025 21:07:21 +0000 (23:07 +0200)
Problem:  confusing error with nested legacy function
          (lacygoill)
Solution: clarify error message E1117 with :def or :func (Hirohito Higashi)

fixes: #17697
closes: #17702

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/errors.h
src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index 6ca05b59fab40a49ef36f7953ac7a4545c6f353a..fd644201cca4bb5ff2d1e598d0da4b5c0a049c6e 100644 (file)
@@ -2885,8 +2885,8 @@ EXTERN char e_assert_fails_fourth_argument[]
        INIT(= N_("E1115: \"assert_fails()\" fourth argument must be a number"));
 EXTERN char e_assert_fails_fifth_argument[]
        INIT(= N_("E1116: \"assert_fails()\" fifth argument must be a string"));
-EXTERN char e_cannot_use_bang_with_nested_def[]
-       INIT(= N_("E1117: Cannot use ! with nested :def"));
+EXTERN char e_cannot_use_bang_with_nested_def_str[]
+       INIT(= N_("E1117: Cannot use ! with nested %s"));
 EXTERN char e_cannot_change_locked_list[]
        INIT(= N_("E1118: Cannot change locked list"));
 EXTERN char e_cannot_change_locked_list_item[]
index e214d9583ba23c87514d9917c234ceed2b4663df..85d672bd2ebdfb452be6a6820717c901456618a1 100644 (file)
@@ -1001,7 +1001,18 @@ def Test_nested_function()
         enddef
       enddef
   END
-  v9.CheckDefFailure(lines, 'E1117:')
+  v9.CheckDefFailure(lines, 'E1117: Cannot use ! with nested :def')
+
+  lines =<< trim END
+      def Outer()
+        function Inner()
+          " comment
+        endfunc
+        function! Inner()
+        endfunc
+      enddef
+  END
+  v9.CheckDefFailure(lines, 'E1117: Cannot use ! with nested :function')
 
   lines =<< trim END
       vim9script
index 1884220baa9cd117a17c8111349c09d49d60702c..fc0f8c58e9351b7c6a448c454626197a60edf72a 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1531,
 /**/
     1530,
 /**/
index 131bab7f47fabbcd8b7723ece0843bfcc6ed260a..a7c412e51d1f52c8e32f0e2e02b38d8632c88f8d 100644 (file)
@@ -1035,7 +1035,8 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
 
     if (eap->forceit)
     {
-       emsg(_(e_cannot_use_bang_with_nested_def));
+       semsg(_(e_cannot_use_bang_with_nested_def_str),
+               eap->cmdidx == CMD_def ? ":def" : ":function");
        return NULL;
     }