summaryrefslogtreecommitdiff
path: root/src/vim9expr.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-17 13:13:32 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-17 13:13:32 +0100
commit4913d420e8e8619cff837372bce87683d6fcaa03 (patch)
tree4485db34731a29ea8bbaded0f984f9633c6bf6a8 /src/vim9expr.c
parent3f0092c141824356b55b11cd3985baaf4df65334 (diff)
downloadvim-git-4913d420e8e8619cff837372bce87683d6fcaa03.tar.gz
patch 9.0.0778: indexing of unknown const type fails during compilationv9.0.0778
Problem: Indexing of unknown const type fails during compilation. Solution: Check for "any" properly. (closes #11389)
Diffstat (limited to 'src/vim9expr.c')
-rw-r--r--src/vim9expr.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/vim9expr.c b/src/vim9expr.c
index 8be8f6b91..854c09d01 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -93,7 +93,8 @@ compile_member(int is_slice, int *keeping_dict, cctx_T *cctx)
vartype = typep->type_curr->tt_type;
idxtype = (((type2_T *)stack->ga_data) + stack->ga_len - 1)->type_curr;
// If the index is a string, the variable must be a Dict.
- if ((typep->type_curr == &t_any || typep->type_curr == &t_unknown)
+ if ((typep->type_curr->tt_type == VAR_ANY
+ || typep->type_curr->tt_type == VAR_UNKNOWN)
&& idxtype == &t_string)
vartype = VAR_DICT;
if (vartype == VAR_STRING || vartype == VAR_LIST || vartype == VAR_BLOB)
@@ -172,8 +173,8 @@ compile_member(int is_slice, int *keeping_dict, cctx_T *cctx)
return FAIL;
}
}
- else if (vartype == VAR_LIST || typep->type_curr == &t_any
- || typep->type_curr == &t_unknown)
+ else if (vartype == VAR_LIST || typep->type_curr->tt_type == VAR_ANY
+ || typep->type_curr->tt_type == VAR_UNKNOWN)
{
if (is_slice)
{
@@ -669,7 +670,7 @@ compile_arguments(
// {sub} argument of substitute() can be compiled if it starts
// with \=
if (isn->isn_type == ISN_PUSHS && isn->isn_arg.string[0] == '\\'
- && isn->isn_arg.string[1] == '=')
+ && isn->isn_arg.string[1] == '=')
compile_string(isn, cctx, 2);
}
@@ -1646,10 +1647,11 @@ bool_on_stack(cctx_T *cctx)
if (type == &t_bool)
return OK;
- if (type == &t_any
- || type == &t_unknown
- || type == &t_number
- || type == &t_number_bool)
+ if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_NUMBER
+ || type == &t_number_bool
+ || type == &t_const_number_bool)
// Number 0 and 1 are OK to use as a bool. "any" could also be a bool.
// This requires a runtime type check.
return generate_COND2BOOL(cctx);