]> granicus.if.org Git - vim/commitdiff
patch 8.1.2262: unpack assignment in function not recognized v8.1.2262
authorBram Moolenaar <Bram@vim.org>
Wed, 6 Nov 2019 14:02:50 +0000 (15:02 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 6 Nov 2019 14:02:50 +0000 (15:02 +0100)
Problem:    Unpack assignment in function not recognized.
Solution:   Skip over "[a, b]". (closes #5051)

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

index 64d178c675c37b0b714e05a198d2efd3686b3746..76b750599e5cac8e68a628f3c603fcbd16db633d 100644 (file)
@@ -303,4 +303,12 @@ E
      END
   endif
   call assert_equal([], check)
+
+  " unpack assignment
+  let [a, b, c] =<< END
+     x
+     \y
+     z
+END
+  call assert_equal(['     x', '     \y', '     z'], [a, b, c])
 endfunc
index a77521290f17ef879685aa9675c6af249d94657a..40eb14401d11dee3a3e3baa0312c2f3cf3bae3a8 100644 (file)
@@ -2482,25 +2482,31 @@ ex_function(exarg_T *eap)
            }
 
            // Check for ":let v =<< [trim] EOF"
+           //       and ":let [a, b] =<< [trim] EOF"
            arg = skipwhite(skiptowhite(p));
-           arg = skipwhite(skiptowhite(arg));
-           if (arg[0] == '=' && arg[1] == '<' && arg[2] =='<'
-                   && ((p[0] == 'l'
-                           && p[1] == 'e'
-                           && (!ASCII_ISALNUM(p[2])
-                               || (p[2] == 't' && !ASCII_ISALNUM(p[3]))))))
+           if (*arg == '[')
+               arg = vim_strchr(arg, ']');
+           if (arg != NULL)
            {
-               p = skipwhite(arg + 3);
-               if (STRNCMP(p, "trim", 4) == 0)
+               arg = skipwhite(skiptowhite(arg));
+               if ( arg[0] == '=' && arg[1] == '<' && arg[2] =='<'
+                       && ((p[0] == 'l'
+                               && p[1] == 'e'
+                               && (!ASCII_ISALNUM(p[2])
+                                   || (p[2] == 't' && !ASCII_ISALNUM(p[3]))))))
                {
-                   // Ignore leading white space.
-                   p = skipwhite(p + 4);
-                   heredoc_trimmed = vim_strnsave(theline,
+                   p = skipwhite(arg + 3);
+                   if (STRNCMP(p, "trim", 4) == 0)
+                   {
+                       // Ignore leading white space.
+                       p = skipwhite(p + 4);
+                       heredoc_trimmed = vim_strnsave(theline,
                                          (int)(skipwhite(theline) - theline));
+                   }
+                   skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
+                   do_concat = FALSE;
+                   is_heredoc = TRUE;
                }
-               skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
-               do_concat = FALSE;
-               is_heredoc = TRUE;
            }
        }
 
index 4ae3f0e49f3311a4f623167028209515e5687d38..e086561669e9023d24c88e0bdb7e033da8f9755d 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2262,
 /**/
     2261,
 /**/