# HG changeset patch # User Christian Brabandt # Date 1695307509 -7200 # Node ID 9062315f9de1aec9a85b48dd1687e475bb0c1f94 # Parent 85615068771dfbdf1f796c4cc1e939ccb5b187ff patch 9.0.1926: Vim9: not enough info in error message Commit: https://github.com/vim/vim/commit/696270bcae0c14029030f14a3f3ca2763a2b39de Author: Ernie Rael Date: Thu Sep 21 16:42:28 2023 +0200 patch 9.0.1926: Vim9: not enough info in error message 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 Co-authored-by: Ernie Rael diff --git a/src/errors.h b/src/errors.h --- a/src/errors.h +++ b/src/errors.h @@ -3411,7 +3411,7 @@ EXTERN char e_cannot_access_private_memb 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"); diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -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; diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -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_f 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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -700,6 +700,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1926, +/**/ 1925, /**/ 1924, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1611,8 +1611,8 @@ lhs_class_member_modifiable(lhs_T *lhs, { 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; }