summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-11-06 15:02:50 +0100
committerBram Moolenaar <Bram@vim.org>2019-11-06 15:02:50 +0100
commit1e673b9eb686459bd0e7fc3f2199dd077546a18e (patch)
treea8d0c54830502a5d7409c32f5def265e230cbe23
parent177c9f2f06b048f4c1e154d29423edf65b128f8c (diff)
patch 8.1.2262: unpack assignment in function not recognizedv8.1.2262
Problem: Unpack assignment in function not recognized. Solution: Skip over "[a, b]". (closes #5051)
-rw-r--r--src/testdir/test_let.vim8
-rw-r--r--src/userfunc.c34
-rw-r--r--src/version.c2
3 files changed, 30 insertions, 14 deletions
diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim
index 64d178c675..76b750599e 100644
--- a/src/testdir/test_let.vim
+++ b/src/testdir/test_let.vim
@@ -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
diff --git a/src/userfunc.c b/src/userfunc.c
index a77521290f..40eb14401d 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -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;
}
}
diff --git a/src/version.c b/src/version.c
index 4ae3f0e49f..e086561669 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2262,
+/**/
2261,
/**/
2260,