summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-06 14:29:09 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-06 14:29:09 +0100
commitbc6f2bf78af28c93b48906408756b797ab2fd7bd (patch)
tree444839f967a56340f95411c85b63cd2537240a16
parentf1d63b9cba9ca91d6367615c6098761c30c6cb5b (diff)
patch 8.2.4886: Vim9: redir in skipped block seen as assignmentv8.2.4886
Problem: Vim9: redir in skipped block seen as assignment. Solution: Check for valid assignment.
-rw-r--r--src/ex_docmd.c4
-rw-r--r--src/testdir/test_vim9_assign.vim8
-rw-r--r--src/version.c2
3 files changed, 13 insertions, 1 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index f78e4edf25..26acc07e0f 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3683,6 +3683,7 @@ find_ex_command(
// "&opt = expr"
// "var = expr" where "var" is a variable name or we are skipping
// (variable declaration might have been skipped).
+ // Not "redir => var" (when skipping).
oplen = assignment_len(skipwhite(p), &heredoc);
if (oplen > 0)
{
@@ -3690,7 +3691,8 @@ find_ex_command(
|| *eap->cmd == '&'
|| *eap->cmd == '$'
|| *eap->cmd == '@'
- || eap->skip
+ || (eap->skip && IS_WHITE_OR_NUL(
+ *(skipwhite(p) + oplen)))
|| lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK)
{
eap->cmdidx = CMD_var;
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index 97a69701d5..36a0ba296b 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -739,6 +739,14 @@ def Test_init_in_for_loop()
v9.CheckDefAndScriptSuccess(lines)
enddef
+def Test_redir_is_not_assign()
+ if false
+ redir => res
+ echo var_job
+ redir END
+ endif
+enddef
+
def Test_extend_list()
# using uninitialized list assigns empty list
var lines =<< trim END
diff --git a/src/version.c b/src/version.c
index 24219311fb..6c4aa52e68 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4886,
+/**/
4885,
/**/
4884,