Patch 8.2.0731
Problem:    Vim9: parsing declarations continues after :finish.
Solution:   Bail out when encountering :finish.
Files:      src/vim9script.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.0730/src/vim9script.c    2020-05-09 22:50:04.751323784 +0200
--- src/vim9script.c    2020-05-10 21:14:58.503672051 +0200
***************
*** 130,135 ****
--- 130,141 ----
            vim_free(((char_u **)(gap->ga_data))[--gap->ga_len]);
            ((char_u **)(gap->ga_data))[gap->ga_len++] = NULL;
        }
+       else if (checkforcmd(&p, "finish", 4))
+       {
+           // TODO: this should not happen below "if false".
+           // Use "if cond | finish | endif as a workaround.
+           break;
+       }
      }
  
      // Compile the :def functions.
*** ../vim-8.2.0730/src/testdir/test_vim9_script.vim    2020-05-10 
19:10:27.972996530 +0200
--- src/testdir/test_vim9_script.vim    2020-05-10 21:19:11.250737326 +0200
***************
*** 1705,1710 ****
--- 1705,1727 ----
        ], 'E488:')
  enddef
  
+ def Test_finish()
+   let lines =<< trim END
+     vim9script
+     let g:res = 'one'
+     if v:false | finish | endif
+     let g:res = 'two'
+     finish
+     let g:res = 'three'
+   END
+   writefile(lines, 'Xfinished')
+   source Xfinished
+   assert_equal('two', g:res)
+ 
+   unlet g:res
+   delete('Xfinished')
+ enddef
+ 
  " Keep this last, it messes up highlighting.
  def Test_substitute_cmd()
    new
*** ../vim-8.2.0730/src/version.c       2020-05-10 19:10:27.972996530 +0200
--- src/version.c       2020-05-10 21:17:05.035201685 +0200
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     731,
  /**/

-- 
>From "know your smileys":
¯\_(ツ)_/¯   Shrug

 /// Bram Moolenaar -- [email protected] -- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005101920.04AJKr7H022723%40masaka.moolenaar.net.

Raspunde prin e-mail lui