comparison src/structs.h @ 26935:ccb9be1cdd71 v8.2.3996

patch 8.2.3996: Vim9: type checking lacks information about declared type Commit: https://github.com/vim/vim/commit/078a46161e8b1b30bf306d6c1f4f0af7c616a989 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 4 15:17:03 2022 +0000 patch 8.2.3996: Vim9: type checking lacks information about declared type 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.
author Bram Moolenaar <Bram@vim.org>
date Tue, 04 Jan 2022 16:30:06 +0100
parents dcd1c244e332
children 7045e9308ca3
comparison
equal deleted inserted replaced
26934:2d3dd8065e25 26935:ccb9be1cdd71
1420 char_u tt_flags; // TTFLAG_ values 1420 char_u tt_flags; // TTFLAG_ values
1421 type_T *tt_member; // for list, dict, func return type 1421 type_T *tt_member; // for list, dict, func return type
1422 type_T **tt_args; // func argument types, allocated 1422 type_T **tt_args; // func argument types, allocated
1423 }; 1423 };
1424 1424
1425 typedef struct {
1426 type_T *type_curr; // current type, value type
1427 type_T *type_decl; // declared type or equal to type_current
1428 } type2_T;
1429
1425 #define TTFLAG_VARARGS 1 // func args ends with "..." 1430 #define TTFLAG_VARARGS 1 // func args ends with "..."
1426 #define TTFLAG_OPTARG 2 // func arg type with "?" 1431 #define TTFLAG_OPTARG 2 // func arg type with "?"
1427 #define TTFLAG_BOOL_OK 4 // can be converted to bool 1432 #define TTFLAG_BOOL_OK 4 // can be converted to bool
1428 #define TTFLAG_STATIC 8 // one of the static types, e.g. t_any 1433 #define TTFLAG_STATIC 8 // one of the static types, e.g. t_any
1429 1434
1505 listitem_T *lv_last; // last item, NULL if none 1510 listitem_T *lv_last; // last item, NULL if none
1506 listitem_T *lv_idx_item; // when not NULL item at index "lv_idx" 1511 listitem_T *lv_idx_item; // when not NULL item at index "lv_idx"
1507 int lv_idx; // cached index of an item 1512 int lv_idx; // cached index of an item
1508 } mat; 1513 } mat;
1509 } lv_u; 1514 } lv_u;
1510 type_T *lv_type; // allocated by alloc_type() 1515 type_T *lv_type; // current type, allocated by alloc_type()
1516 type_T *lv_decl_type; // declared type, allocated by alloc_type()
1511 list_T *lv_copylist; // copied list used by deepcopy() 1517 list_T *lv_copylist; // copied list used by deepcopy()
1512 list_T *lv_used_next; // next list in used lists list 1518 list_T *lv_used_next; // next list in used lists list
1513 list_T *lv_used_prev; // previous list in used lists list 1519 list_T *lv_used_prev; // previous list in used lists list
1514 int lv_refcount; // reference count 1520 int lv_refcount; // reference count
1515 int lv_len; // number of items 1521 int lv_len; // number of items
1569 char dv_lock; // zero, VAR_LOCKED, VAR_FIXED 1575 char dv_lock; // zero, VAR_LOCKED, VAR_FIXED
1570 char dv_scope; // zero, VAR_SCOPE, VAR_DEF_SCOPE 1576 char dv_scope; // zero, VAR_SCOPE, VAR_DEF_SCOPE
1571 int dv_refcount; // reference count 1577 int dv_refcount; // reference count
1572 int dv_copyID; // ID used by deepcopy() 1578 int dv_copyID; // ID used by deepcopy()
1573 hashtab_T dv_hashtab; // hashtab that refers to the items 1579 hashtab_T dv_hashtab; // hashtab that refers to the items
1574 type_T *dv_type; // allocated by alloc_type() 1580 type_T *dv_type; // current type, allocated by alloc_type()
1581 type_T *dv_decl_type; // declared type, allocated by alloc_type()
1575 dict_T *dv_copydict; // copied dict used by deepcopy() 1582 dict_T *dv_copydict; // copied dict used by deepcopy()
1576 dict_T *dv_used_next; // next dict in used dicts list 1583 dict_T *dv_used_next; // next dict in used dicts list
1577 dict_T *dv_used_prev; // previous dict in used dicts list 1584 dict_T *dv_used_prev; // previous dict in used dicts list
1578 }; 1585 };
1579 1586