]> granicus.if.org Git - vim/commitdiff
patch 8.2.0731: Vim9: parsing declarations continues after :finish v8.2.0731
authorBram Moolenaar <Bram@vim.org>
Sun, 10 May 2020 19:20:29 +0000 (21:20 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 10 May 2020 19:20:29 +0000 (21:20 +0200)
Problem:    Vim9: parsing declarations continues after :finish.
Solution:   Bail out when encountering :finish.

src/testdir/test_vim9_script.vim
src/version.c
src/vim9script.c

index 0b99eec5d38162779e63435926c04e1f18c4bc4d..e85da5a8001be245610485010c404141fedfd347 100644 (file)
@@ -1705,6 +1705,23 @@ def Test_vim9_comment_not_compiled()
       ], '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
index d89763bfc191737e0790e3c33af8883e509ce3c2..efb3c3187c0cf0099cc6b05ee83b5d6cec640ba3 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    731,
 /**/
     730,
 /**/
index 8bc1962bfd49d43935c5c33bc163da412b79c331..4d7e8ee46fe4c01b508fed0b099a20ea190789f2 100644 (file)
@@ -130,6 +130,12 @@ ex_vim9script(exarg_T *eap)
            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.