Patch 8.2.1455

4 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 14, 2020, 4:44:59 PM8/14/20
to vim...@googlegroups.com

Patch 8.2.1455
Problem: Vim9: crash when using typecast before constant.
Solution: Generate constant before checking type. Add tets.
Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1454/src/vim9compile.c 2020-08-14 22:16:29.586423086 +0200
--- src/vim9compile.c 2020-08-14 22:36:53.720574591 +0200
***************
*** 3501,3511 ****
if (want_type != NULL)
{
garray_T *stack = &cctx->ctx_type_stack;
! type_T *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;
}
--- 3501,3512 ----
if (want_type != NULL)
{
garray_T *stack = &cctx->ctx_type_stack;
! 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)
{
if (need_type(actual, want_type, -1, cctx, FALSE) == FAIL)
return FAIL;
}
***************
*** 5016,5021 ****
--- 5017,5023 ----
goto theend;
if (*skipwhite(p) != ']')
{
+ // this should not happen
emsg(_(e_missbrac));
goto theend;
}
*** ../vim-8.2.1454/src/testdir/test_vim9_expr.vim 2020-08-14 22:16:29.586423086 +0200
--- src/testdir/test_vim9_expr.vim 2020-08-14 22:43:05.706345080 +0200
***************
*** 1324,1329 ****
--- 1324,1335 ----
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
*** ../vim-8.2.1454/src/version.c 2020-08-14 22:16:29.586423086 +0200
--- src/version.c 2020-08-14 22:37:45.444276244 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1455,
/**/

--
$ echo pizza > /dev/oven

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages