]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.2012: Vim9: error message can be more accurate v9.0.2012
authorErnie Rael <errael@raelity.com>
Wed, 11 Oct 2023 19:22:12 +0000 (21:22 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 11 Oct 2023 19:22:12 +0000 (21:22 +0200)
Problem:  Vim9: error message can be more accurate
Solution: Fix the error messages

Fix message for some single use error messages.

closes: #13312

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
src/errors.h
src/eval.c
src/testdir/test_listdict.vim
src/testdir/test_vim9_assign.vim
src/version.c

index 2474e27d4ce51d58b26d3243132b3839c1e8e986..50cf6698da23bf5943c6b33b438bc01433769ab7 100644 (file)
@@ -1771,8 +1771,8 @@ EXTERN char e_less_targets_than_list_items[]
        INIT(= N_("E687: Less targets than List items"));
 EXTERN char e_more_targets_than_list_items[]
        INIT(= N_("E688: More targets than List items"));
-EXTERN char e_can_only_index_list_dictionary_or_blob[]
-       INIT(= N_("E689: Can only index a List, Dictionary or Blob"));
+EXTERN char e_index_not_allowed_after_str_str[]
+       INIT(= N_("E689: Index not allowed after a %s: %s"));
 EXTERN char e_missing_in_after_for[]
        INIT(= N_("E690: Missing \"in\" after :for"));
 EXTERN char e_can_only_compare_list_with_list[]
@@ -3081,8 +3081,8 @@ EXTERN char e_libsodium_decryption_failed_premature[]
 #ifdef FEAT_EVAL
 EXTERN char e_no_white_space_allowed_after_str_str[]
        INIT(= N_("E1202: No white space allowed after '%s': %s"));
-EXTERN char e_dot_can_only_be_used_on_dictionary_str[]
-       INIT(= N_("E1203: Dot can only be used on a dictionary: %s"));
+EXTERN char e_dot_not_allowed_after_str_str[]
+       INIT(= N_("E1203: Dot not allowed after a %s: %s"));
 #endif
 EXTERN char e_regexp_number_after_dot_pos_search_chr[]
        INIT(= N_("E1204: No Number allowed after .: '\\%%%c'"));
index 93109effb92eb378175395dd938c4923c755be1b..8b26eb189fb0683db9e7a8b82626c2aafa6cbde3 100644 (file)
@@ -1375,9 +1375,9 @@ get_lval(
                      && v_type != VAR_OBJECT
                      && v_type != VAR_CLASS)
        {
-           // TODO: have a message with obj/class, not just dict,
            if (!quiet)
-               semsg(_(e_dot_can_only_be_used_on_dictionary_str), name);
+               semsg(_(e_dot_not_allowed_after_str_str),
+                                               vartype_name(v_type), name);
            return NULL;
        }
        if (v_type != VAR_LIST
@@ -1386,9 +1386,9 @@ get_lval(
                && v_type != VAR_OBJECT
                && v_type != VAR_CLASS)
        {
-           // TODO: have a message with obj/class, not just dict/list/blob,
            if (!quiet)
-               emsg(_(e_can_only_index_list_dictionary_or_blob));
+               semsg(_(e_index_not_allowed_after_str_str),
+                                               vartype_name(v_type), name);
            return NULL;
        }
 
index b7c8ad73462a1a456e669849bf0e0c6109653d68..09e73ef9cae6188924ef0ba3e166057ef5daee20 100644 (file)
@@ -435,13 +435,13 @@ func Test_dict_assign()
     let n = 0
     let n.key = 3
   END
-  call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3')
+  call v9.CheckScriptFailure(lines, 'E1203: Dot not allowed after a number: n.key = 3')
   let lines =<< trim END
     vim9script
     var n = 0
     n.key = 3
   END
-  call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3')
+  call v9.CheckScriptFailure(lines, 'E1203: Dot not allowed after a number: n.key = 3')
   let lines =<< trim END
     var n = 0
     n.key = 3
index 07afadb0c81fe2bddb83201224dfd63ed185a0f0..3a187774ec2a449af78bc7fa97f8ec98ce16ae7a 100644 (file)
@@ -1278,7 +1278,7 @@ def Test_assignment_dict()
     var n: any
     n.key = 5
   END
-  v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot can only be used on a dictionary: n.key = 5'], 2)
+  v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot not allowed after a number: n.key = 5'], 2)
 enddef
 
 def Test_assignment_local()
index 441acfd12fde058e74d52298b06ed9f1eb92f09e..5b919069ca997e356875bfaeb30a46560864d59a 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2012,
 /**/
     2011,
 /**/