From 8331310c060ed2bfe9916470b3c10f484f875a6e Mon Sep 17 00:00:00 2001 From: Hirohito Higashi Date: Tue, 8 Jul 2025 23:07:21 +0200 Subject: [PATCH] patch 9.1.1531: confusing error with nested legacy function 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 Signed-off-by: Christian Brabandt --- src/errors.h | 4 ++-- src/testdir/test_vim9_func.vim | 13 ++++++++++++- src/version.c | 2 ++ src/vim9compile.c | 3 ++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/errors.h b/src/errors.h index 6ca05b59fa..fd644201cc 100644 --- a/src/errors.h +++ b/src/errors.h @@ -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[] diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index e214d9583b..85d672bd2e 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -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 diff --git a/src/version.c b/src/version.c index 1884220baa..fc0f8c58e9 100644 --- a/src/version.c +++ b/src/version.c @@ -719,6 +719,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1531, /**/ 1530, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 131bab7f47..a7c412e51d 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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; }