]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3185: Vim9: start of inline function found in comment line v8.2.3185
authorBram Moolenaar <Bram@vim.org>
Mon, 19 Jul 2021 19:04:23 +0000 (21:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 19 Jul 2021 19:04:23 +0000 (21:04 +0200)
Problem:    Vim9: start of inline function found in comment line.
Solution:   Do not check for inline function in comment line. (closes #8589)

src/testdir/test_vim9_expr.vim
src/userfunc.c
src/version.c

index e7c08f4af0c829fa24a6df0a8e7610847ba0a908..49109c7df4e02364ff88619019523065be7e8b2e 100644 (file)
@@ -2075,6 +2075,10 @@ def Test_expr7_lambda_block()
         })
       assert_equal(['no', 'yes', 'no'], dll)
 
+      # ignored_inline(0, (_) => {
+      #   echo 'body'
+      # })
+
       sandbox var Safe = (nr: number): number => {
           return nr + 7
         }
index 3dfa68097221bf6ab90fe1143669f0ada2389c9d..79e711c0a55b889e477fe5c23e62b442a0a5a809 100644 (file)
@@ -866,26 +866,29 @@ get_function_body(
                }
            }
 
-           // Check for nested inline function.
-           end = p + STRLEN(p) - 1;
-           while (end > p && VIM_ISWHITE(*end))
-               --end;
-           if (end > p && *end == '{')
+           if (nesting_def[nesting] ? *p != '#' : *p != '"')
            {
-               --end;
+               // Not a comment line: check for nested inline function.
+               end = p + STRLEN(p) - 1;
                while (end > p && VIM_ISWHITE(*end))
                    --end;
-               if (end > p + 2 && end[-1] == '=' && end[0] == '>')
+               if (end > p && *end == '{')
                {
-                   // found trailing "=> {", start of an inline function
-                   if (nesting == MAX_FUNC_NESTING - 1)
-                       emsg(_(e_function_nesting_too_deep));
-                   else
+                   --end;
+                   while (end > p && VIM_ISWHITE(*end))
+                       --end;
+                   if (end > p + 2 && end[-1] == '=' && end[0] == '>')
                    {
-                       ++nesting;
-                       nesting_def[nesting] = TRUE;
-                       nesting_inline[nesting] = TRUE;
-                       indent += 2;
+                       // found trailing "=> {", start of an inline function
+                       if (nesting == MAX_FUNC_NESTING - 1)
+                           emsg(_(e_function_nesting_too_deep));
+                       else
+                       {
+                           ++nesting;
+                           nesting_def[nesting] = TRUE;
+                           nesting_inline[nesting] = TRUE;
+                           indent += 2;
+                       }
                    }
                }
            }
index c6e3fafc5a0a4de45df4bf05d6736f95f11b11b4..04354c2aa17c64aec2c1f2ac9f403bfcd0425b62 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3185,
 /**/
     3184,
 /**/