Mercurial > vim
comparison src/structs.h @ 32863:a39314fa9495 v9.0.1741
patch 9.0.1741: No type checking in interfaces
Commit: https://github.com/vim/vim/commit/c5d2744c045f9ad058cbc799f2434d90a6d83516
Author: LemonBoy <thatlemon@gmail.com>
Date: Sat Aug 19 13:02:35 2023 +0200
patch 9.0.1741: No type checking in interfaces
Problem: No type checking in interfaces
Solution: Implement member type check in vim9 interfaces
Most of the code is a small refactoring to allow the use of a where_T
for signaling the type mismatch, the type checking itself is pretty
simple.
Improve where_T error reports
Let the caller explicitly define the kind of location it's referring to
and free the WT_ARGUMENT enum from its catch-all role.
Implement type checking for interface methods
Follows closely the logic used for type-checking the members.
closes: #12844
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 19 Aug 2023 13:15:04 +0200 |
parents | 757409cf4e8a |
children | 41482b74f548 |
comparison
equal
deleted
inserted
replaced
32862:19cba3b0df5f | 32863:a39314fa9495 |
---|---|
4762 MAGIC_OFF = 2, // "\M" or 'magic' off | 4762 MAGIC_OFF = 2, // "\M" or 'magic' off |
4763 MAGIC_ON = 3, // "\m" or 'magic' | 4763 MAGIC_ON = 3, // "\m" or 'magic' |
4764 MAGIC_ALL = 4 // "\v" very magic | 4764 MAGIC_ALL = 4 // "\v" very magic |
4765 } magic_T; | 4765 } magic_T; |
4766 | 4766 |
4767 typedef enum { | |
4768 WT_UNKNOWN = 0, // Unknown or unspecified location | |
4769 WT_ARGUMENT, | |
4770 WT_VARIABLE, | |
4771 WT_MEMBER, | |
4772 WT_METHOD, | |
4773 } wherekind_T; | |
4774 | |
4767 // Struct used to pass to error messages about where the error happened. | 4775 // Struct used to pass to error messages about where the error happened. |
4768 typedef struct { | 4776 typedef struct { |
4769 char *wt_func_name; // function name or NULL | 4777 char *wt_func_name; // function name or NULL |
4770 char wt_index; // argument or variable index, 0 means unknown | 4778 char wt_index; // argument or variable index, 0 means unknown |
4771 char wt_variable; // "variable" when TRUE, "argument" otherwise | 4779 wherekind_T wt_kind; // "variable" when TRUE, "argument" otherwise |
4772 } where_T; | 4780 } where_T; |
4773 | 4781 |
4774 #define WHERE_INIT {NULL, 0, 0} | 4782 #define WHERE_INIT {NULL, 0, WT_UNKNOWN} |
4775 | 4783 |
4776 // Struct passed to get_v_event() and restore_v_event(). | 4784 // Struct passed to get_v_event() and restore_v_event(). |
4777 typedef struct { | 4785 typedef struct { |
4778 int sve_did_save; | 4786 int sve_did_save; |
4779 hashtab_T sve_hashtab; | 4787 hashtab_T sve_hashtab; |