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 -- b...@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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202008142044.07EKipNt149284%40masaka.moolenaar.net.

Raspunde prin e-mail lui