Patch 8.2.2763
Problem:    Vim9: cannot use type in for loop unpack at script level.
Solution:   Advance over the type name.
Files:      src/evalvars.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.2762/src/evalvars.c      2021-04-13 21:47:59.540306700 +0200
--- src/evalvars.c      2021-04-14 13:25:55.601230051 +0200
***************
*** 1523,1529 ****
            else
            {
                set_var_lval(&lv, p, tv, copy, flags, op, var_idx);
!               arg_end = p;
            }
        }
        clear_lval(&lv);
--- 1523,1529 ----
            else
            {
                set_var_lval(&lv, p, tv, copy, flags, op, var_idx);
!               arg_end = lv.ll_name_end;
            }
        }
        clear_lval(&lv);
*** ../vim-8.2.2762/src/testdir/test_vim9_script.vim    2021-04-13 
21:47:59.544306690 +0200
--- src/testdir/test_vim9_script.vim    2021-04-14 13:29:19.461966581 +0200
***************
*** 2336,2343 ****
        endfor
        assert_equal(6, total)
  
!       # loop over string
        var res = ''
        for c in 'aéc̀d'
          res ..= c .. '-'
        endfor
--- 2336,2357 ----
        endfor
        assert_equal(6, total)
  
!       # with type
!       total = 0
!       for n: number in [1, 2, 3]
!         total += n
!       endfor
!       assert_equal(6, total)
! 
!       # unpack with type
        var res = ''
+       for [n: number, s: string] in [[1, 'a'], [2, 'b']]
+         res ..= n .. s
+       endfor
+       assert_equal('1a2b', res)
+ 
+       # loop over string
+       res = ''
        for c in 'aéc̀d'
          res ..= c .. '-'
        endfor
***************
*** 2364,2376 ****
        assert_equal([{a: 'Cat', counter: 12}], foo)
    END
    CheckDefAndScriptSuccess(lines)
- 
-   # TODO: should also work at script level
-   var res = ""
-   for [n: number, s: string] in [[1, 'a'], [2, 'b']]
-     res ..= n .. s
-   endfor
-   assert_equal('1a2b', res)
  enddef
  
  def Test_for_loop_fails()
--- 2378,2383 ----
*** ../vim-8.2.2762/src/version.c       2021-04-14 12:39:56.656454570 +0200
--- src/version.c       2021-04-14 13:25:43.281170545 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2763,
  /**/

-- 
# echo reboot >universe
# chmod +x universe
# ./universe

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202104141131.13EBVOPA1221849%40masaka.moolenaar.net.

Raspunde prin e-mail lui