Patch 8.2.4508
Problem:    Vim9: cannot assign to a global variable on the command line.
Solution:   Allow using :vim9cmd for assignment on the command line.
Files:      src/evalvars.c, src/testdir/test_vim9_script.vim,
            src/testdir/dumps/Test_vim9_reject_declaration.dump,
            src/testdir/dumps/Test_vim9_reject_declaration_1.dump,
            src/testdir/dumps/Test_vim9_reject_declaration_2.dump


*** ../vim-8.2.4507/src/evalvars.c      2022-03-03 17:05:17.527121052 +0000
--- src/evalvars.c      2022-03-05 10:55:44.478283465 +0000
***************
*** 754,765 ****
      void
  ex_var(exarg_T *eap)
  {
      if (!in_vim9script())
      {
        semsg(_(e_str_cannot_be_used_in_legacy_vim_script), ":var");
        return;
      }
!     if (current_sctx.sc_sid == 0)
      {
        emsg(_(e_cannot_declare_variable_on_command_line));
        return;
--- 754,767 ----
      void
  ex_var(exarg_T *eap)
  {
+     char_u *p = eap->cmd;
+ 
      if (!in_vim9script())
      {
        semsg(_(e_str_cannot_be_used_in_legacy_vim_script), ":var");
        return;
      }
!     if (current_sctx.sc_sid == 0 && checkforcmd_noparen(&p, "var", 3))
      {
        emsg(_(e_cannot_declare_variable_on_command_line));
        return;
*** ../vim-8.2.4507/src/testdir/test_vim9_script.vim    2022-03-04 
17:10:15.959626537 +0000
--- src/testdir/test_vim9_script.vim    2022-03-05 10:51:30.055849894 +0000
***************
*** 3365,3371 ****
  def Run_test_reject_declaration()
    var buf = g:RunVimInTerminal('', {'rows': 6})
    term_sendkeys(buf, ":vim9cmd var x: number\<CR>")
!   g:VerifyScreenDump(buf, 'Test_vim9_reject_declaration', {})
  
    # clean up
    g:StopVimInTerminal(buf)
--- 3365,3374 ----
  def Run_test_reject_declaration()
    var buf = g:RunVimInTerminal('', {'rows': 6})
    term_sendkeys(buf, ":vim9cmd var x: number\<CR>")
!   g:VerifyScreenDump(buf, 'Test_vim9_reject_declaration_1', {})
!   term_sendkeys(buf, ":\<CR>")
!   term_sendkeys(buf, ":vim9cmd g:foo = 123 | echo g:foo\<CR>")
!   g:VerifyScreenDump(buf, 'Test_vim9_reject_declaration_2', {})
  
    # clean up
    g:StopVimInTerminal(buf)
*** ../vim-8.2.4507/src/testdir/dumps/Test_vim9_reject_declaration.dump 
2022-03-03 17:05:17.527121052 +0000
--- src/testdir/dumps/Test_vim9_reject_declaration.dump 1970-01-01 
00:00:00.000000000 +0000
***************
*** 1,6 ****
- |~+0#4040ff13#ffffff0| @73
- |~| @73
- |~| @73
- |~| @73
- |E+0#ffffff16#e000002|1|0|7|9|:| |C|a|n@1|o|t| |d|e|c|l|a|r|e| |a| 
|v|a|r|i|a|b|l|e| |o|n| |t|h|e| |c|o|m@1|a|n|d| |l|i|n|e| +0#0000000#ffffff0@22
- |P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o| 
|c|o|n|t|i|n|u|e> +0#0000000&@35
--- 0 ----
*** ../vim-8.2.4507/src/testdir/dumps/Test_vim9_reject_declaration_1.dump       
2022-03-05 11:05:03.970787749 +0000
--- src/testdir/dumps/Test_vim9_reject_declaration_1.dump       2022-03-03 
16:48:49.314192776 +0000
***************
*** 0 ****
--- 1,6 ----
+ |~+0#4040ff13#ffffff0| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |E+0#ffffff16#e000002|1|0|7|9|:| |C|a|n@1|o|t| |d|e|c|l|a|r|e| |a| 
|v|a|r|i|a|b|l|e| |o|n| |t|h|e| |c|o|m@1|a|n|d| |l|i|n|e| +0#0000000#ffffff0@22
+ |P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o| 
|c|o|n|t|i|n|u|e> +0#0000000&@35
*** ../vim-8.2.4507/src/testdir/dumps/Test_vim9_reject_declaration_2.dump       
2022-03-05 11:05:03.974787768 +0000
--- src/testdir/dumps/Test_vim9_reject_declaration_2.dump       2022-03-05 
10:51:39.999816375 +0000
***************
*** 0 ****
--- 1,6 ----
+ > +0&#ffffff0@74
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |1+0#0000000&|2|3| @53|0|,|0|-|1| @8|A|l@1| 
*** ../vim-8.2.4507/src/version.c       2022-03-04 23:22:22.217834504 +0000
--- src/version.c       2022-03-05 11:04:51.782735028 +0000
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     4508,
  /**/

-- 
An error has occurred.  Hit any user to continue.

 /// 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/20220305110631.B624A1C02C5%40moolenaar.net.

Raspunde prin e-mail lui