diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-25 13:20:41 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-25 13:20:41 +0100 |
commit | 3868f59466ed5ff1c5624f40b93c0034ce62cb82 (patch) | |
tree | 92513853943730fc96b34f7489ce9a0fefc42cc5 | |
parent | 9e68c32563d8c9ffe1ac04ecd4ccd730af66b97c (diff) | |
download | vim-git-3868f59466ed5ff1c5624f40b93c0034ce62cb82.tar.gz |
patch 8.2.2210: Vim9: allocating a type to set TTFLAG_BOOL_OKv8.2.2210
Problem: Vim9: allocating a type to set TTFLAG_BOOL_OK.
Solution: Add t_number_bool.
-rw-r--r-- | src/globals.h | 1 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 11 | ||||
-rw-r--r-- | src/vim9type.c | 15 |
4 files changed, 7 insertions, 22 deletions
diff --git a/src/globals.h b/src/globals.h index d7887bb62..39ef83e49 100644 --- a/src/globals.h +++ b/src/globals.h @@ -403,6 +403,7 @@ EXTERN type_T t_void INIT6(VAR_VOID, 0, 0, TTFLAG_STATIC, NULL, NULL); EXTERN type_T t_bool INIT6(VAR_BOOL, 0, 0, TTFLAG_STATIC, NULL, NULL); EXTERN type_T t_special INIT6(VAR_SPECIAL, 0, 0, TTFLAG_STATIC, NULL, NULL); EXTERN type_T t_number INIT6(VAR_NUMBER, 0, 0, TTFLAG_STATIC, NULL, NULL); +EXTERN type_T t_number_bool INIT6(VAR_NUMBER, 0, 0, TTFLAG_STATIC|TTFLAG_BOOL_OK, NULL, NULL); EXTERN type_T t_float INIT6(VAR_FLOAT, 0, 0, TTFLAG_STATIC, NULL, NULL); EXTERN type_T t_string INIT6(VAR_STRING, 0, 0, TTFLAG_STATIC, NULL, NULL); EXTERN type_T t_blob INIT6(VAR_BLOB, 0, 0, TTFLAG_STATIC, NULL, NULL); diff --git a/src/version.c b/src/version.c index ba291afe7..018bfd52a 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2210, +/**/ 2209, /**/ 2208, diff --git a/src/vim9compile.c b/src/vim9compile.c index fdc805b48..53a61051c 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -931,17 +931,8 @@ generate_PUSHNR(cctx_T *cctx, varnumber_T number) isn->isn_arg.number = number; if (number == 0 || number == 1) - { - type_T *type = get_type_ptr(cctx->ctx_type_list); - // A 0 or 1 number can also be used as a bool. - if (type != NULL) - { - type->tt_type = VAR_NUMBER; - type->tt_flags = TTFLAG_BOOL_OK; - ((type_T **)stack->ga_data)[stack->ga_len - 1] = type; - } - } + ((type_T **)stack->ga_data)[stack->ga_len - 1] = &t_number_bool; return OK; } diff --git a/src/vim9type.c b/src/vim9type.c index 4ea32a7fe..7d8df695f 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -376,18 +376,9 @@ typval2type(typval_T *tv, garray_T *type_gap) if (type != NULL && type != &t_bool && (tv->v_type == VAR_NUMBER && (tv->vval.v_number == 0 || tv->vval.v_number == 1))) - { - type_T *newtype = get_type_ptr(type_gap); - - // Number 0 and 1 and expression with "&&" or "||" can also be used - // for bool. - if (newtype != NULL) - { - *newtype = *type; - newtype->tt_flags = TTFLAG_BOOL_OK; - type = newtype; - } - } + // Number 0 and 1 and expression with "&&" or "||" can also be used for + // bool. + type = &t_number_bool; return type; } |