summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-15 20:36:28 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-15 20:36:28 +0200
commitcd6b4f300189b4920f7ee7f0204338e91210674b (patch)
treec1c04ae3d2b0e7e6c7aacfb571d4d29663f14d70 /src/vim9compile.c
parent4bba16d252da6f072d311f9b3ebb50101d6d2eaf (diff)
downloadvim-git-cd6b4f300189b4920f7ee7f0204338e91210674b.tar.gz
patch 8.2.3353: Vim9: type of argument for negate not checked at compile timev8.2.3353
Problem: Vim9: type of argument for negate not checked at compile time. Solution: Add a compile time check.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index e29d96377..5b47746e3 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4210,10 +4210,15 @@ compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end)
--p;
if (*p == '-' || *p == '+')
{
- int negate = *p == '-';
- isn_T *isn;
+ int negate = *p == '-';
+ isn_T *isn;
+ garray_T *stack = &cctx->ctx_type_stack;
+ type_T *type;
+
+ type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
+ if (need_type(type, &t_number, -1, 0, cctx, FALSE, FALSE) == FAIL)
+ return FAIL;
- // TODO: check type
while (p > start && (p[-1] == '-' || p[-1] == '+'))
{
--p;
@@ -4222,11 +4227,11 @@ compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end)
}
// only '-' has an effect, for '+' we only check the type
if (negate)
+ {
isn = generate_instr(cctx, ISN_NEGATENR);
- else
- isn = generate_instr(cctx, ISN_CHECKNR);
- if (isn == NULL)
- return FAIL;
+ if (isn == NULL)
+ return FAIL;
+ }
}
else if (numeric_only)
{
@@ -5809,7 +5814,6 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
goto theend;
r = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);
}
- // TODO: warning for trailing text?
theend:
vim_free(lambda_name);
@@ -5852,7 +5856,6 @@ generate_loadvar(
switch (dest)
{
case dest_option:
- // TODO: check the option exists
generate_LOAD(cctx, ISN_LOADOPT, 0, name, type);
break;
case dest_global: