Patch 8.2.3054
Problem:    Vim9: unpack assignment using "_" after semicolon fails.
Solution:   Drop the expression result. (closes #8453)
Files:      src/vim9compile.c, src/errors.h, src/testdir/test_vim9_assign.vim


*** ../vim-8.2.3053/src/vim9compile.c   2021-06-26 13:28:30.863226604 +0200
--- src/vim9compile.c   2021-06-26 13:50:32.540554049 +0200
***************
*** 6598,6603 ****
--- 6598,6604 ----
      int               var_count = 0;
      int               var_idx;
      int               semicolon = 0;
+     int               did_generate_slice = FALSE;
      garray_T  *instr = &cctx->ctx_instr;
      garray_T    *stack = &cctx->ctx_type_stack;
      char_u    *op;
***************
*** 6801,6806 ****
--- 6802,6808 ----
                else if (semicolon && var_idx == var_count - 1)
                {
                    // For "[var; var] = expr" get the rest of the list
+                   did_generate_slice = TRUE;
                    if (generate_SLICE(cctx, var_count - 1) == FAIL)
                        goto theend;
                }
***************
*** 7010,7017 ****
            var_start = skipwhite(lhs.lhs_dest_end + 1);
      }
  
!     // for "[var, var] = expr" drop the "expr" value
!     if (var_count > 0 && !semicolon)
      {
        if (generate_instr_drop(cctx, ISN_DROP, 1) == NULL)
            goto theend;
--- 7012,7020 ----
            var_start = skipwhite(lhs.lhs_dest_end + 1);
      }
  
!     // For "[var, var] = expr" drop the "expr" value.
!     // Also for "[var, var; _] = expr".
!     if (var_count > 0 && (!semicolon || !did_generate_slice))
      {
        if (generate_instr_drop(cctx, ISN_DROP, 1) == NULL)
            goto theend;
*** ../vim-8.2.3053/src/errors.h        2021-06-25 21:31:03.375070663 +0200
--- src/errors.h        2021-06-26 13:57:45.791696837 +0200
***************
*** 318,324 ****
  EXTERN char e_missing_matching_bracket_after_dict_key[]
        INIT(= N_("E1139: Missing matching bracket after dict key"));
  EXTERN char e_for_argument_must_be_sequence_of_lists[]
!       INIT(= N_("E1140: For argument must be a sequence of lists"));
  EXTERN char e_indexable_type_required[]
        INIT(= N_("E1141: Indexable type required"));
  EXTERN char e_non_empty_string_required[]
--- 318,324 ----
  EXTERN char e_missing_matching_bracket_after_dict_key[]
        INIT(= N_("E1139: Missing matching bracket after dict key"));
  EXTERN char e_for_argument_must_be_sequence_of_lists[]
!       INIT(= N_("E1140: :for argument must be a sequence of lists"));
  EXTERN char e_indexable_type_required[]
        INIT(= N_("E1141: Indexable type required"));
  EXTERN char e_non_empty_string_required[]
*** ../vim-8.2.3053/src/testdir/test_vim9_assign.vim    2021-06-26 
13:28:30.863226604 +0200
--- src/testdir/test_vim9_assign.vim    2021-06-26 13:56:33.307840082 +0200
***************
*** 289,294 ****
--- 289,304 ----
      assert_equal(1, v1)
      assert_equal(2, v2)
  
+     var reslist = []
+     for text in ['aaa {bbb} ccc', 'ddd {eee} fff']
+       var before: string
+       var middle: string
+       var after: string
+       [_, before, middle, after; _] = 
text->matchlist('\(.\{-\}\){\(.\{-\}\)}\(.*\)')
+       reslist->add(before)->add(middle)->add(after)
+     endfor
+     assert_equal(['aaa ', 'bbb', ' ccc', 'ddd ', 'eee', ' fff'], reslist)
+ 
      var a = 1
      var b = 3
      [a, b] += [2, 4]
*** ../vim-8.2.3053/src/version.c       2021-06-26 13:28:30.863226604 +0200
--- src/version.c       2021-06-26 13:51:38.624423144 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3054,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
36. You miss more than five meals a week downloading the latest games from
    Apogee.

 /// 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/202106261200.15QC07e4313130%40masaka.moolenaar.net.

Raspunde prin e-mail lui