]> granicus.if.org Git - vim/commitdiff
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list v8.2.2071
authorBram Moolenaar <Bram@vim.org>
Mon, 30 Nov 2020 20:12:19 +0000 (21:12 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 30 Nov 2020 20:12:19 +0000 (21:12 +0100)
Problem:    Vim9: list assign doesn't except empty remainder list.
Solution:   Recognize list assignment with ";".

src/ex_docmd.c
src/testdir/test_vim9_assign.vim
src/version.c

index d530c0823a651c3e2c44608d7a0631646d4e16bf..1d5d2dedc23d04486e28eb9a10bfc22e382b7ac8 100644 (file)
@@ -3356,7 +3356,14 @@ find_ex_command(
            if (*eap->cmd == '[')
            {
                p = to_name_const_end(eap->cmd);
-               if (p == eap->cmd || *skipwhite(p) != '=')
+               if (p == eap->cmd && *p == '[')
+               {
+                   int count = 0;
+                   int semicolon = FALSE;
+
+                   p = skip_var_list(eap->cmd, TRUE, &count, &semicolon, TRUE);
+               }
+               if (p == NULL || p == eap->cmd || *skipwhite(p) != '=')
                {
                    eap->cmdidx = CMD_eval;
                    return eap->cmd;
index 2e08e8bb7e5c2f6e0819a10c0da0d515322e7a55..421229fd01013cbbdbc384a0c87c87b159a83d21 100644 (file)
@@ -632,30 +632,33 @@ def Test_assignment_default()
 enddef
 
 def Test_assignment_var_list()
-  var v1: string
-  var v2: string
-  var vrem: list<string>
-  [v1] = ['aaa']
-  assert_equal('aaa', v1)
-
-  [v1, v2] = ['one', 'two']
-  assert_equal('one', v1)
-  assert_equal('two', v2)
-
-  [v1, v2; vrem] = ['one', 'two']
-  assert_equal('one', v1)
-  assert_equal('two', v2)
-  assert_equal([], vrem)
-
-  [v1, v2; vrem] = ['one', 'two', 'three']
-  assert_equal('one', v1)
-  assert_equal('two', v2)
-  assert_equal(['three'], vrem)
-
-  [&ts, &sw] = [3, 4]
-  assert_equal(3, &ts)
-  assert_equal(4, &sw)
-  set ts=8 sw=4
+  var lines =<< trim END
+      var v1: string
+      var v2: string
+      var vrem: list<string>
+      [v1] = ['aaa']
+      assert_equal('aaa', v1)
+
+      [v1, v2] = ['one', 'two']
+      assert_equal('one', v1)
+      assert_equal('two', v2)
+
+      [v1, v2; vrem] = ['one', 'two']
+      assert_equal('one', v1)
+      assert_equal('two', v2)
+      assert_equal([], vrem)
+
+      [v1, v2; vrem] = ['one', 'two', 'three']
+      assert_equal('one', v1)
+      assert_equal('two', v2)
+      assert_equal(['three'], vrem)
+
+      [&ts, &sw] = [3, 4]
+      assert_equal(3, &ts)
+      assert_equal(4, &sw)
+      set ts=8 sw=4
+  END
+  CheckDefAndScriptSuccess(lines)
 enddef
 
 def Test_assignment_vim9script()
index 4eb7f4b5910b0b8bcce46aa9c16b7ca0b285cca0..84571336799274db190a1ce96ec63862b790e4bf 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2071,
 /**/
     2070,
 /**/