summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-14 22:44:25 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-14 22:44:25 +0200
commitd1103587cf339feb8c77d282f7f7e92b7cff5add (patch)
tree53c392cd8e30d46df0ebdfa11d0232e26eb5a000
parent79e8db9a218ef111934594024a5cd8b1f93acada (diff)
patch 8.2.1455: Vim9: crash when using typecast before constantv8.2.1455
Problem: Vim9: crash when using typecast before constant. Solution: Generate constant before checking type. Add tets.
-rw-r--r--src/testdir/test_vim9_expr.vim6
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c6
3 files changed, 12 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index fb07586bc2..38a332601a 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1324,6 +1324,12 @@ let $TESTVAR = 'testvar'
def Test_expr7t()
let ls: list<string> = ['a', <string>g:string_empty]
let ln: list<number> = [<number>g:anint, <number>g:alsoint]
+ let nr = <number>234
+ assert_equal(234, nr)
+
+ call CheckDefFailure(["let x = <nr>123"], 'E1010:')
+ call CheckDefFailure(["let x = <number >123"], 'E1068:')
+ call CheckDefFailure(["let x = <number 123"], 'E1104:')
enddef
" test low level expression
diff --git a/src/version.c b/src/version.c
index e6d929e1a8..e873a9c07e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1455,
+/**/
1454,
/**/
1453,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 5c4547d08d..920628444e 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3501,11 +3501,12 @@ compile_expr7t(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (want_type != NULL)
{
garray_T *stack = &cctx->ctx_type_stack;
- type_T *actual = ((type_T **)stack->ga_data)[stack->ga_len - 1];
+ type_T *actual;
+ generate_ppconst(cctx, ppconst);
+ actual = ((type_T **)stack->ga_data)[stack->ga_len - 1];
if (check_type(want_type, actual, FALSE) == FAIL)
{
- generate_ppconst(cctx, ppconst);
if (need_type(actual, want_type, -1, cctx, FALSE) == FAIL)
return FAIL;
}
@@ -5016,6 +5017,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
goto theend;
if (*skipwhite(p) != ']')
{
+ // this should not happen
emsg(_(e_missbrac));
goto theend;
}