]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1926: Vim9: not enough info in error message v9.0.1926
authorErnie Rael <errael@raelity.com>
Thu, 21 Sep 2023 14:42:28 +0000 (16:42 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 21 Sep 2023 14:42:28 +0000 (16:42 +0200)
Problem:  Vim9: not enough info in error message
Solution: Add class name, change member to variable, quote names

closes: #13136

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_vim9_class.vim
src/version.c
src/vim9compile.c

index f1373a42c4038a26ece18eaecda3fbe1a1269b93..40e16f1c0db4453796ca4c4b1dd868fc72c571e7 100644 (file)
@@ -3411,7 +3411,7 @@ EXTERN char e_cannot_access_private_member_str[]
        INIT(= N_("E1333: Cannot access private member: %s"));
 // E1334 unused
 EXTERN char e_member_is_not_writable_str[]
-       INIT(= N_("E1335: Member is not writable: %s"));
+       INIT(= N_("E1335: Variable \"%s\" in class \"%s\" is not writable"));
 #endif
 EXTERN char e_internal_error_shortmess_too_long[]
        INIT(= "E1336: Internal error: shortmess too long");
index 93b840e61ee1bcca116e1dac6cab9244f98af9f6..3f8ce5ffefb8fdb2e3c6737b542751d510814483 100644 (file)
@@ -1570,7 +1570,7 @@ get_lval(
                                if ((flags & GLV_READ_ONLY) == 0)
                                {
                                    semsg(_(e_member_is_not_writable_str),
-                                           om->ocm_name);
+                                           om->ocm_name, cl->class_name);
                                    return NULL;
                                }
                                break;
index f57bf44d04624d72d5ba8f926b030f71355ad5ba..6c338167fd8f77e27a46a99c1b85c884b1806420 100644 (file)
@@ -646,7 +646,7 @@ def Test_assignment_nested_type()
 
     Test_assign_to_nested_typed_member()
   END
-  v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "value"')
+  v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "Inner" is not writable')
 
   # Assignment where target item is read only script level
   lines =<< trim END
@@ -669,7 +669,7 @@ def Test_assignment_nested_type()
     script_outer.inner.value = 1
     assert_equal(1, script_inner.value)
   END
-  v9.CheckSourceFailure(lines, 'E1335: Member is not writable: value')
+  v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "Inner" is not writable')
 enddef
 
 def Test_assignment_with_operator()
@@ -1243,7 +1243,7 @@ def Test_class_variable_access()
       var b = B.new()
       b.Foo()
   END
-  v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "ro_class_var"')
+  v9.CheckSourceFailure(lines, 'E1335: Variable "ro_class_var" in class "A" is not writable')
 
   # A private class variable cannot be accessed from a child class
   lines =<< trim END
@@ -4269,7 +4269,7 @@ def Test_readonly_member_change_in_def_func()
     enddef
     T()
   END
-  v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "val"')
+  v9.CheckSourceFailure(lines, 'E1335: Variable "val" in class "A" is not writable')
 enddef
 
 " Test for reading and writing a class member from a def function
@@ -5541,7 +5541,7 @@ def Test_nested_object_assignment()
     var d = D.new()
     T(d)
   END
-  v9.CheckSourceFailure(lines, 'E46: Cannot change read-only variable "value"')
+  v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "A" is not writable')
 enddef
 
 " Test for calling methods using a null object
index 3f4c648ab9cd7d9c85e6fbe2b7e5b179d4203b66..ced912523c581ac0f2a46ba34b2b85de3c8d2cd5 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1926,
 /**/
     1925,
 /**/
index a8d8c7d220bf790ab43847e6b6676a7bb6f98872..16898e32c739b82d0268c5df4d75a35e827cd6ed 100644 (file)
@@ -1611,8 +1611,8 @@ lhs_class_member_modifiable(lhs_T *lhs, char_u    *var_start, cctx_T *cctx)
     {
        char *msg = (m->ocm_access == VIM_ACCESS_PRIVATE)
                                ? e_cannot_access_private_member_str
-                               : e_cannot_change_readonly_variable_str;
-       semsg(_(msg), m->ocm_name);
+                               : e_member_is_not_writable_str;
+       semsg(_(msg), m->ocm_name, cl->class_name);
        return FALSE;
     }