Patch 8.2.2878
Problem:    Vim9: for loop list unpack only allows for one "_".
Solution:   Drop the value when the variable is "_". (closes #8232)
Files:      src/vim9compile.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.2877/src/vim9compile.c   2021-05-18 21:46:27.716961252 +0200
--- src/vim9compile.c   2021-05-22 21:38:40.990397825 +0200
***************
*** 7776,7781 ****
--- 7776,7787 ----
                                                     0, 0, type, name) == FAIL)
                goto failed;
        }
+       else if (varlen == 1 && *arg == '_')
+       {
+           // Assigning to "_": drop the value.
+           if (generate_instr_drop(cctx, ISN_DROP, 1) == NULL)
+               goto failed;
+       }
        else
        {
            if (lookup_local(arg, varlen, NULL, cctx) == OK)
*** ../vim-8.2.2877/src/testdir/test_vim9_script.vim    2021-04-28 
20:40:39.799852470 +0200
--- src/testdir/test_vim9_script.vim    2021-05-22 21:36:27.779094661 +0200
***************
*** 2500,2505 ****
--- 2500,2511 ----
        endfor
        assert_equal(['global', 'buf', 'win', 'tab', '1', '2', '3', '4'], slist)
        unlet! g:globalvar b:bufvar w:winvar t:tabvar
+ 
+       var res = []
+       for [_, n, _] in [[1, 2, 3], [4, 5, 6]]
+         res->add(n)
+       endfor
+       assert_equal([2, 5], res)
    END
    CheckDefAndScriptSuccess(lines)
  
*** ../vim-8.2.2877/src/version.c       2021-05-22 17:12:03.974528010 +0200
--- src/version.c       2021-05-22 21:35:07.099517132 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2878,
  /**/

-- 
We do not stumble over mountains, but over molehills.
                                Confucius

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202105221941.14MJfMns893513%40masaka.moolenaar.net.

Raspunde prin e-mail lui