Patch 8.2.2762
Problem:    Vim9: function line truncated when compiling.
Solution:   Copy the line before processing it. (closes #8101)
Files:      src/vim9compile.c, src/testdir/test_vim9_disassemble.vim


*** ../vim-8.2.2761/src/vim9compile.c   2021-04-13 21:47:59.544306690 +0200
--- src/vim9compile.c   2021-04-14 12:34:52.565554528 +0200
***************
*** 8486,8491 ****
--- 8486,8492 ----
        cctx_T      *outer_cctx)
  {
      char_u    *line = NULL;
+     char_u    *line_to_free = NULL;
      char_u    *p;
      char      *errormsg = NULL;       // error message
      cctx_T    cctx;
***************
*** 8647,8652 ****
--- 8648,8661 ----
  #endif
                break;
            }
+           // Make a copy, splitting off nextcmd and removing trailing spaces
+           // may change it.
+           if (line != NULL)
+           {
+               line = vim_strsave(line);
+               vim_free(line_to_free);
+               line_to_free = line;
+           }
        }
  
        CLEAR_FIELD(ea);
***************
*** 9095,9100 ****
--- 9104,9110 ----
      if (do_estack_push)
        estack_pop();
  
+     vim_free(line_to_free);
      free_imported(&cctx);
      free_locals(&cctx);
      ga_clear(&cctx.ctx_type_stack);
*** ../vim-8.2.2761/src/testdir/test_vim9_disassemble.vim       2021-04-11 
18:24:40.498508499 +0200
--- src/testdir/test_vim9_disassemble.vim       2021-04-14 12:37:52.960893966 
+0200
***************
*** 386,391 ****
--- 386,418 ----
          res)
  enddef
  
+ def s:BlobIndexSlice()
+   var b: blob = 0z112233
+   echo b[1]
+   echo b[1 : 2]
+ enddef
+ 
+ def Test_disassemble_blob_index_slice()
+   var res = execute('disass s:BlobIndexSlice')
+   assert_match('<SNR>\d*_BlobIndexSlice\_s*' ..
+         'var b: blob = 0z112233\_s*' ..
+         '\d PUSHBLOB 0z112233\_s*' ..
+         '\d STORE $0\_s*' ..
+         'echo b\[1\]\_s*' ..
+         '\d LOAD $0\_s*' ..
+         '\d PUSHNR 1\_s*' ..
+         '\d BLOBINDEX\_s*' ..
+         '\d ECHO 1\_s*' ..
+         'echo b\[1 : 2\]\_s*' ..
+         '\d LOAD $0\_s*' ..
+         '\d PUSHNR 1\_s*' ..
+         '\d\+ PUSHNR 2\_s*' ..
+         '\d\+ BLOBSLICE\_s*' ..
+         '\d\+ ECHO 1\_s*' ..
+         '\d\+ RETURN 0',
+         res)
+ enddef
+ 
  def s:ScriptFuncUnlet()
    g:somevar = "value"
    unlet g:somevar
***************
*** 2018,2022 ****
--- 2045,2061 ----
          res)
  enddef
  
+ def s:EchoMessages()
+   echohl ErrorMsg | echom v:exception | echohl NONE
+ enddef
+ 
+ def Test_disassemble_nextcmd()
+   # splitting commands and removing trailing blanks should not change the line
+   var res = execute('disass s:EchoMessages')
+   assert_match('<SNR>\d*_EchoMessages\_s*' ..
+         'echohl ErrorMsg | echom v:exception | echohl NONE',
+         res)
+ enddef
+ 
  
  " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.2761/src/version.c       2021-04-14 11:15:05.336785013 +0200
--- src/version.c       2021-04-14 12:38:34.408745669 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2762,
  /**/

-- 
>From "know your smileys":
 <|-) Chinese
 <|-( Chinese and doesn't like these kind of jokes

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/202104141040.13EAeX6R1211158%40masaka.moolenaar.net.

Raspunde prin e-mail lui