changeset 21471:126dcb0411ed v8.2.1286

patch 8.2.1286: Vim9: No error when using a type to a window variable Commit: https://github.com/vim/vim/commit/43e969d3f98766824c18d20b84f2fab00feef683 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 23 21:14:43 2020 +0200 patch 8.2.1286: Vim9: No error when using a type to a window variable Problem: Vim9: No error when using a type to a window variable Solution: Recognize the syntax and give an error. (closes https://github.com/vim/vim/issues/6521)
author Bram Moolenaar <Bram@vim.org>
date Thu, 23 Jul 2020 21:15:05 +0200
parents f0304ef8ac7d
children d17bb9011c44
files src/ex_docmd.c src/testdir/test_vim9_script.vim src/version.c
diffstat 3 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3324,6 +3324,14 @@ find_ex_command(
 		return eap->cmd;
 	    }
 	}
+
+	// Recognize using a type for a w:, b:, t: or g: variable:
+	// "w:varname: number = 123".
+	if (eap->cmd[1] == ':' && *p == ':')
+	{
+	    eap->cmdidx = CMD_eval;
+	    return eap->cmd;
+	}
     }
 #endif
 
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -376,6 +376,15 @@ def Test_assignment_failure()
 
   call assert_fails('s/^/\=Mess()/n', 'E794:')
   call CheckDefFailure(['let var: dict<number'], 'E1009:')
+
+  call CheckDefFailure(['w:foo: number = 10'],
+                       'E488: Trailing characters: : number = 1')
+  call CheckDefFailure(['t:foo: bool = true'],
+                       'E488: Trailing characters: : bool = true')
+  call CheckDefFailure(['b:foo: string = "x"'],
+                       'E488: Trailing characters: : string = "x"')
+  call CheckDefFailure(['g:foo: number = 123'],
+                       'E488: Trailing characters: : number = 123')
 enddef
 
 def Test_unlet()
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1286,
+/**/
     1285,
 /**/
     1284,