summaryrefslogtreecommitdiff
path: root/src/structs.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-04 15:17:03 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-04 15:17:03 +0000
commit078a46161e8b1b30bf306d6c1f4f0af7c616a989 (patch)
tree334c2fa968e1641524028ac18afedf5980446e64 /src/structs.h
parent9acf2d8be93f3b50607279e7f3484b019675d0a7 (diff)
downloadvim-git-078a46161e8b1b30bf306d6c1f4f0af7c616a989.tar.gz
patch 8.2.3996: Vim9: type checking lacks information about declared typev8.2.3996
Problem: Vim9: type checking for list and dict lacks information about declared type. Solution: Add dv_decl_type and lv_decl_type. Refactor the type stack to store two types in each entry.
Diffstat (limited to 'src/structs.h')
-rw-r--r--src/structs.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/structs.h b/src/structs.h
index 4e770f118..7d040eb6f 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1422,6 +1422,11 @@ struct type_S {
type_T **tt_args; // func argument types, allocated
};
+typedef struct {
+ type_T *type_curr; // current type, value type
+ type_T *type_decl; // declared type or equal to type_current
+} type2_T;
+
#define TTFLAG_VARARGS 1 // func args ends with "..."
#define TTFLAG_OPTARG 2 // func arg type with "?"
#define TTFLAG_BOOL_OK 4 // can be converted to bool
@@ -1507,7 +1512,8 @@ struct listvar_S
int lv_idx; // cached index of an item
} mat;
} lv_u;
- type_T *lv_type; // allocated by alloc_type()
+ type_T *lv_type; // current type, allocated by alloc_type()
+ type_T *lv_decl_type; // declared type, allocated by alloc_type()
list_T *lv_copylist; // copied list used by deepcopy()
list_T *lv_used_next; // next list in used lists list
list_T *lv_used_prev; // previous list in used lists list
@@ -1571,7 +1577,8 @@ struct dictvar_S
int dv_refcount; // reference count
int dv_copyID; // ID used by deepcopy()
hashtab_T dv_hashtab; // hashtab that refers to the items
- type_T *dv_type; // allocated by alloc_type()
+ type_T *dv_type; // current type, allocated by alloc_type()
+ type_T *dv_decl_type; // declared type, allocated by alloc_type()
dict_T *dv_copydict; // copied dict used by deepcopy()
dict_T *dv_used_next; // next dict in used dicts list
dict_T *dv_used_prev; // previous dict in used dicts list