patch 9.0.1999: Vim9: some error messages can be improved
Problem: Vim9: some error messages can be improved
Solution: Mention the defining class for variable access error message
closes: #13272
Signed-off-by: Christian Brabandt <cb@256bit.org>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Co-authored-by: Ernie Rael <errael@raelity.com>
diff --git a/src/eval.c b/src/eval.c
index a9f7112..d9fbec2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1105,26 +1105,28 @@
#endif
if (cl_exec == NULL || cl_exec != cl)
{
+ char *msg = NULL;
switch (om->ocm_access)
{
case VIM_ACCESS_PRIVATE:
- semsg(_(e_cannot_access_private_variable_str),
- om->ocm_name, cl->class_name);
- return FAIL;
+ msg = e_cannot_access_private_variable_str;
+ break;
case VIM_ACCESS_READ:
// If [idx] or .key following, read only OK.
if (*p == '[' || *p == '.')
break;
if ((flags & GLV_READ_ONLY) == 0)
- {
- semsg(_(e_variable_is_not_writable_str),
- om->ocm_name, cl->class_name);
- return FAIL;
- }
+ msg = e_variable_is_not_writable_str;
break;
case VIM_ACCESS_ALL:
break;
}
+ if (msg != NULL)
+ {
+ emsg_var_cl_define(msg, om->ocm_name, 0, cl);
+ return FAIL;
+ }
+
}
return OK;
}