]> granicus.if.org Git - vim/commitdiff
patch 8.2.0682: Vim9: parsing function argument type can get stuck v8.2.0682
authorBram Moolenaar <Bram@vim.org>
Sat, 2 May 2020 17:04:58 +0000 (19:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 2 May 2020 17:04:58 +0000 (19:04 +0200)
Problem:    Vim9: parsing function argument type can get stuck.
Solution:   Bail out when not making progress.

src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index 0fd28924a37768d4f37d4f5a5221f2e7571bf93b..e1b3b7ffd6cda536efcfb1d6b68cb8621073d69a 100644 (file)
@@ -113,6 +113,7 @@ def Test_call_wrong_args()
   call CheckDefFailure(['TakesOneArg()'], 'E119:')
   call CheckDefFailure(['TakesOneArg(11, 22)'], 'E118:')
   call CheckDefFailure(['bufnr(xxx)'], 'E1001:')
+  call CheckScriptFailure(['def Func(Ref: func(s: string))'], 'E475:')
 enddef
 
 " Default arg and varargs
index 982ac1f8873da319c014a09e5139c748caa02893..21cda476a55f49d6bb09feb7c6211784b7a3c83f 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    682,
 /**/
     681,
 /**/
index 5644c50358571ff0f42c756a65021579bdfed6be..eb84e3590904a849f5212b82ff5a0369421e9b4f 100644 (file)
@@ -1663,7 +1663,11 @@ skip_type(char_u *start)
        ++p;
        while (*p != ')' && *p != NUL)
        {
+           char_u *sp = p;
+
            p = skip_type(p);
+           if (p == sp)
+               return p;  // syntax error
            if (*p == ',')
                p = skipwhite(p + 1);
        }