]> granicus.if.org Git - vim/commitdiff
patch 8.2.1286: Vim9: No error when using a type to a window variable v8.2.1286
authorBram Moolenaar <Bram@vim.org>
Thu, 23 Jul 2020 19:14:43 +0000 (21:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 23 Jul 2020 19:14:43 +0000 (21:14 +0200)
Problem:    Vim9: No error when using a type to a window variable
Solution:   Recognize the syntax and give an error. (closes #6521)

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

index bd3de8ff8f9b5e3299acf00ffa5a13195215ce21..85747d5f4cae94058dd0bd4a4155b817c9395559 100644 (file)
@@ -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
 
index fd572d742fc4be293456f147cdc354f3c2500c63..d7464856b3a8e4581167e7533887698d776a68ad 100644 (file)
@@ -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()
index 5563bd1fa647138e406da7e1d4282395b005f0c8..fc86f15dc2c217aeba04c0e5db7debb99dacf8a7 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1286,
 /**/
     1285,
 /**/