changeset 20504:7fb80f486aad v8.2.0806

patch 8.2.0806: using "func!" after vim9script gives confusing error Commit: https://github.com/vim/vim/commit/74fae513f8032cfa9e129eedc33454f0bf68668b Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 21 21:50:58 2020 +0200 patch 8.2.0806: using "func!" after vim9script gives confusing error Problem: using "func!" after vim9script gives confusing error. Solution: Give E477. (closes https://github.com/vim/vim/issues/6107)
author Bram Moolenaar <Bram@vim.org>
date Thu, 21 May 2020 22:00:03 +0200
parents 34d4df8db24c
children af5d9cf7e7a1
files src/testdir/test_vim9_script.vim src/version.c src/vim9script.c
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -136,7 +136,7 @@ def Test_assignment_dict()
   let dict2: dict<number> = #{one: 1, two: 2}
   let dict3: dict<string> = #{key: 'value'}
   let dict4: dict<any> = #{one: 1, two: '2'}
-  let dict5: dict<blob> = #{one: 0z01, tw: 0z02}
+  let dict5: dict<blob> = #{one: 0z01, two: 0z02}
 
   call CheckDefExecFailure(['let dd = {}', 'dd[""] = 6'], 'E713:')
 
@@ -1721,6 +1721,11 @@ def Test_vim9_comment_not_compiled()
       'dsearch /pat/#comment',
       'bwipe!',
       ], 'E488:')
+
+  CheckScriptFailure([
+      'vim9script',
+      'func! SomeFunc()',
+      ], 'E477:')
 enddef
 
 def Test_finish()
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    806,
+/**/
     805,
 /**/
     804,
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -84,6 +84,12 @@ ex_vim9script(exarg_T *eap)
 	{
 	    int		    lnum_start = SOURCING_LNUM - 1;
 
+	    if (*p == '!')
+	    {
+		emsg(_(e_nobang));
+		break;
+	    }
+
 	    // Handle :function and :def by calling def_function().
 	    // It will read upto the matching :endded or :endfunction.
 	    eap->cmdidx = *line == 'f' ? CMD_function : CMD_def;