summaryrefslogtreecommitdiffstats
path: root/src/errors.h
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-09-15 20:14:55 +0200
committerChristian Brabandt <cb@256bit.org>2023-09-15 20:14:55 +0200
commitc30a90d9b2c029f794cea502f6b824f71e4876dd (patch)
tree53c789bae67beb6fe099686fcc6894b2c6fdb7b8 /src/errors.h
parent35928ee8f80ea721e92bb856c8ecde2cced46bb9 (diff)
patch 9.0.1898: Vim9: restrict access to static varsv9.0.1898
Problem: Vim9: restrict access to static vars and methods Solution: Class members are accesible only from the class where they are defined. Based on the #13004 discussion, the following changes are made: 1) Static variables and methods are accessible only using the class name and inside the class where they are defined. 2) Static variables and methods can be used without the class name in the class where they are defined. 3) Static variables of a super class are not copied to the sub class. 4) A sub class can declare a class variable with the same name as the super class. 5) When a method or member is found during compilation, use more specific error messages. This aligns the Vim9 class variable/method implementation with the Dart implementation. Also while at it, ignore duplicate class and object methods. The access level of an object method can however be changed in a subclass. For the tests, use the new CheckSourceFailure() function instead of the CheckScriptFailure() function in the tests. closes: #13086 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/errors.h')
-rw-r--r--src/errors.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/errors.h b/src/errors.h
index 0d53fa84cd..6184037df8 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -3411,16 +3411,14 @@ EXTERN char e_public_member_name_cannot_start_with_underscore_str[]
INIT(= N_("E1332: Public member name cannot start with underscore: %s"));
EXTERN char e_cannot_access_private_member_str[]
INIT(= N_("E1333: Cannot access private member: %s"));
-EXTERN char e_object_member_not_found_str[]
- INIT(= N_("E1334: Object member not found: %s"));
EXTERN char e_member_is_not_writable_str[]
INIT(= N_("E1335: Member is not writable: %s"));
#endif
EXTERN char e_internal_error_shortmess_too_long[]
INIT(= "E1336: Internal error: shortmess too long");
#ifdef FEAT_EVAL
-EXTERN char e_class_member_not_found_str[]
- INIT(= N_("E1337: Class member not found: %s"));
+EXTERN char e_class_member_str_not_found_in_class_str[]
+ INIT(= N_("E1337: Class member \"%s\" not found in class \"%s\""));
EXTERN char e_member_not_found_on_class_str_str[]
INIT(= N_("E1338: Member not found on class \"%s\": %s"));
#endif
@@ -3488,7 +3486,6 @@ EXTERN char e_cannot_access_private_method_str[]
INIT(= N_("E1366: Cannot access private method: %s"));
EXTERN char e_member_str_of_interface_str_has_different_access[]
INIT(= N_("E1367: Access level of member \"%s\" of interface \"%s\" is different"));
-
EXTERN char e_static_cannot_be_followed_by_this[]
INIT(= N_("E1368: Static cannot be followed by \"this\" in a member name"));
EXTERN char e_duplicate_member_str[]
@@ -3501,6 +3498,16 @@ EXTERN char e_abstract_method_in_concrete_class[]
INIT(= N_("E1372: Abstract method \"%s\" cannot be defined in a concrete class"));
EXTERN char e_abstract_method_str_not_found[]
INIT(= N_("E1373: Abstract method \"%s\" is not implemented"));
+EXTERN char e_class_member_str_accessible_only_inside_class_str[]
+ INIT(= N_("E1374: Class member \"%s\" accessible only inside class \"%s\""));
+EXTERN char e_class_member_str_accessible_only_using_class_str[]
+ INIT(= N_("E1375: Class member \"%s\" accessible only using class \"%s\""));
+EXTERN char e_object_member_str_accessible_only_using_object_str[]
+ INIT(= N_("E1376: Object member \"%s\" accessible only using class \"%s\" object"));
+EXTERN char e_static_member_not_supported_in_interface[]
+ INIT(= N_("E1377: Static member is not supported in an interface"));
+EXTERN char e_method_str_of_class_str_has_different_access[]
+ INIT(= N_("E1378: Access level of method \"%s\" is different in class \"%s\""));
EXTERN char e_cannot_mix_positional_and_non_positional_str[]
INIT(= N_("E1400: Cannot mix positional and non-positional arguments: %s"));
EXTERN char e_fmt_arg_nr_unused_str[]
@@ -3521,4 +3528,4 @@ EXTERN char e_aptypes_is_null_nr_str[]
INIT(= "E1408: Internal error: ap_types or ap_types[idx] is NULL: %d: %s");
EXTERN char e_interface_static_direct_access_str[]
INIT(= N_("E1409: Cannot directly access interface \"%s\" static member \"%s\""));
-// E1371 - E1399 unused
+// E1376 - E1399 unused