Patch 8.2.2077

2020-12-01 Fir de Conversatie Bram Moolenaar


Patch 8.2.2077
Problem:Build failure with small features.
Solution:   Add #ifdef.
Files:  src/structs.h, src/ex_docmd.c


*** ../vim-8.2.2076/src/structs.h   2020-12-01 20:12:20.788108786 +0100
--- src/structs.h   2020-12-01 21:46:01.741272234 +0100
***
*** 4155,4161 
--- 4155,4163 
  int   save_finish_op;
  int   save_opcount;
  int   save_reg_executing;
+ #ifdef FEAT_EVAL
  int   save_script_version;
+ #endif
  tasave_T  tabuf;
  } save_state_T;
  
*** ../vim-8.2.2076/src/ex_docmd.c  2020-12-01 20:12:20.792108768 +0100
--- src/ex_docmd.c  2020-12-01 21:42:02.154180918 +0100
***
*** 7994,8005 
  sst->save_finish_op = finish_op;
  sst->save_opcount = opcount;
  sst->save_reg_executing = reg_executing;
- sst->save_script_version = current_sctx.sc_version;
  
  msg_scroll = FALSE;   // no msg scrolling in Normal mode
  restart_edit = 0; // don't go to Insert mode
  p_im = FALSE; // don't use 'insertmode'
  current_sctx.sc_version = 1;// not in Vim9 script
  
  /*
   * Save the current typeahead.  This is required to allow using ":normal"
--- 7994,8007 
  sst->save_finish_op = finish_op;
  sst->save_opcount = opcount;
  sst->save_reg_executing = reg_executing;
  
  msg_scroll = FALSE;   // no msg scrolling in Normal mode
  restart_edit = 0; // don't go to Insert mode
  p_im = FALSE; // don't use 'insertmode'
+ #ifdef FEAT_EVAL
+ sst->save_script_version = current_sctx.sc_version;
  current_sctx.sc_version = 1;// not in Vim9 script
+ #endif
  
  /*
   * Save the current typeahead.  This is required to allow using ":normal"
***
*** 8023,8029 
--- 8025,8033 
  opcount = sst->save_opcount;
  reg_executing = sst->save_reg_executing;
  msg_didout |= sst->save_msg_didout;   // don't reset msg_didout now
+ #ifdef FEAT_EVAL
  current_sctx.sc_version = sst->save_script_version;
+ #endif
  
  // Restore the state (needed when called from a function executed for
  // 'indentexpr'). Update the mouse and cursor, they may have changed.
*** ../vim-8.2.2076/src/version.c   2020-12-01 21:27:47.125151362 +0100
--- src/version.c   2020-12-01 21:47:27.004947180 +0100
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 2077,
  /**/

-- 
FATHER: We are here today to witness the union of two young people in the
joyful bond of the holy wedlock.  Unfortunately, one of them, my son
Herbert, has just fallen to his death.
   [Murmurs from CROWD;  the BRIDE smiles with relief, coughs.]
 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\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/202012012048.0B1KmNco3914957%40masaka.moolenaar.net.


Re: Patch 8.2.2074

2020-12-01 Fir de Conversatie Tony Mechelynck
Fatal eror compiling ex_docmd.c with Tiny or Small features:

linux-2iyu:~/.build/vim/vim-hg/src/shadow-tiny # (make || echo 'exit
status' $? ; date) 2>&1 |tee -a make.log
[...]
gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -fno-strength-reduce -Wall
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1-o objects/ex_docmd.o
ex_docmd.c
ex_docmd.c: In function ‘save_current_state’:
ex_docmd.c:7997:32: error: ‘current_sctx’ undeclared (first use in
this function); did you mean ‘current_sent’?
 sst->save_script_version = current_sctx.sc_version;
^~~~
current_sent
ex_docmd.c:7997:32: note: each undeclared identifier is reported only
once for each function it appears in
ex_docmd.c: In function ‘restore_current_state’:
ex_docmd.c:8026:5: error: ‘current_sctx’ undeclared (first use in this
function); did you mean ‘current_sent’?
 current_sctx.sc_version = sst->save_script_version;
 ^~~~
 current_sent
make: *** [Makefile:3231: objects/ex_docmd.o] Error 1
exit status 2
Tue  1 Dec 21:30:00 CET 2020

On Tue, Dec 1, 2020 at 8:13 PM Bram Moolenaar  wrote:
>
>
> Patch 8.2.2074
> Problem:Vim9: using :normal from Vim9 script can't handle range.
> Solution:   Execute a :normal command in legacy script context. (closes #7401)
> Files:  src/structs.h, src/ex_docmd.c, src/testdir/test_vim9_script.vim
>
>
> *** ../vim-8.2.2073/src/structs.h   2020-11-15 20:32:54.167882094 +0100
> --- src/structs.h   2020-12-01 19:40:47.567677152 +0100
> ***
> *** 4155,4160 
> --- 4155,4161 
>   int   save_finish_op;
>   int   save_opcount;
>   int   save_reg_executing;
> + int   save_script_version;
>   tasave_T  tabuf;
>   } save_state_T;
>
> *** ../vim-8.2.2073/src/ex_docmd.c  2020-11-30 21:12:15.747157517 +0100
> --- src/ex_docmd.c  2020-12-01 20:09:09.256981924 +0100
> ***
> *** 7994,8003 
>   sst->save_finish_op = finish_op;
>   sst->save_opcount = opcount;
>   sst->save_reg_executing = reg_executing;
>
> ! msg_scroll = FALSE;   // no msg scrolling in Normal mode
> ! restart_edit = 0; // don't go to Insert mode
> ! p_im = FALSE; // don't use 'insertmode'
>
>   /*
>* Save the current typeahead.  This is required to allow using 
> ":normal"
> --- 7994,8005 
>   sst->save_finish_op = finish_op;
>   sst->save_opcount = opcount;
>   sst->save_reg_executing = reg_executing;
> + sst->save_script_version = current_sctx.sc_version;
>
> ! msg_scroll = FALSE;   // no msg scrolling in Normal mode
> ! restart_edit = 0; // don't go to Insert mode
> ! p_im = FALSE; // don't use 'insertmode'
> ! current_sctx.sc_version = 1;// not in Vim9 script
>
>   /*
>* Save the current typeahead.  This is required to allow using 
> ":normal"
> ***
> *** 8021,8026 
> --- 8023,8029 
>   opcount = sst->save_opcount;
>   reg_executing = sst->save_reg_executing;
>   msg_didout |= sst->save_msg_didout;   // don't reset msg_didout now
> + current_sctx.sc_version = sst->save_script_version;
>
>   // Restore the state (needed when called from a function executed for
>   // 'indentexpr'). Update the mouse and cursor, they may have changed.
> *** ../vim-8.2.2073/src/testdir/test_vim9_script.vim2020-12-01 
> 16:30:40.161598319 +0100
> --- src/testdir/test_vim9_script.vim2020-12-01 20:08:19.749218836 +0100
> ***
> *** 2958,2963 
> --- 2958,2976 
> bwipe!
>   enddef
>
> + def InvokeNormal()
> +   exe "norm! :m+1\r"
> + enddef
> +
> + def Test_invoke_normal_in_visual_mode()
> +   xnoremap  call InvokeNormal()
> +   new
> +   setline(1, ['aaa', 'bbb'])
> +   feedkeys("V\", 'xt')
> +   assert_equal(['bbb', 'aaa'], getline(1, 2))
> +   xunmap 
> + enddef
> +
>   " Keep this last, it messes up highlighting.
>   def Test_substitute_cmd()
> new
> *** ../vim-8.2.2073/src/version.c   2020-12-01 16:30:40.165598305 +0100
> --- src/version.c   2020-12-01 20:07:21.473504964 +0100
> ***
> *** 752,753 
> --- 752,755 
>   {   /* Add new patch number below this line */
> + /**/
> + 2074,
>   /**/
>
> --
> The early bird gets the worm. The second mouse gets the cheese.
>
>  /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
> ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\  an exciting new programming language -- http://www.Zimbu.org///
>  \\\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

Patch 8.2.2076

2020-12-01 Fir de Conversatie Bram Moolenaar


Patch 8.2.2076
Problem:MS-Windows console: sometimes drops typed characters.
Solution:   Do not wait longer than 10 msec for input. (issue #7164)
Files:  src/os_win32.c


*** ../vim-8.2.2075/src/os_win32.c  2020-11-10 22:03:37.027341067 +0100
--- src/os_win32.c  2020-12-01 21:24:51.469772668 +0100
***
*** 1588,1613 
{
DWORD dwWaitTime = dwEndTime - dwNow;
  
! # ifdef FEAT_JOB_CHANNEL
!   // Check channel while waiting for input.
!   if (dwWaitTime > 100)
!   {
!   dwWaitTime = 100;
!   // If there is readahead then parse_queued_messages() timed out
!   // and we should call it again soon.
!   if (channel_any_readahead())
!   dwWaitTime = 10;
!   }
! # endif
! # ifdef FEAT_BEVAL_GUI
!   if (p_beval && dwWaitTime > 100)
!   // The 'balloonexpr' may indirectly invoke a callback while
!   // waiting for a character, need to check often.
!   dwWaitTime = 100;
! # endif
  # ifdef FEAT_MZSCHEME
!   if (mzthreads_allowed() && p_mzq > 0
!   && (msec < 0 || (long)dwWaitTime > p_mzq))
dwWaitTime = p_mzq; // don't wait longer than 'mzquantum'
  # endif
  # ifdef FEAT_TIMERS
--- 1588,1601 
{
DWORD dwWaitTime = dwEndTime - dwNow;
  
!   // Don't wait for more than 11 msec to avoid dropping characters,
!   // check channel while waiting for input and handle a callback from
!   // 'balloonexpr'.
!   if (dwWaitTime > 11)
!   dwWaitTime = 11;
! 
  # ifdef FEAT_MZSCHEME
!   if (mzthreads_allowed() && p_mzq > 0 && (long)dwWaitTime > p_mzq)
dwWaitTime = p_mzq; // don't wait longer than 'mzquantum'
  # endif
  # ifdef FEAT_TIMERS
*** ../vim-8.2.2075/src/version.c   2020-12-01 21:08:01.969599029 +0100
--- src/version.c   2020-12-01 21:26:51.205348465 +0100
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 2076,
  /**/

-- 
GUEST:He's killed the best man!
SECOND GUEST: (holding a limp WOMAN) He's killed my auntie.
FATHER:   No, please!  This is supposed to be a happy occasion!  Let's
  not bicker and argue about who killed who ...
 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\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/202012012028.0B1KSOrg3904948%40masaka.moolenaar.net.


Patch 8.2.2075

2020-12-01 Fir de Conversatie Bram Moolenaar


Patch 8.2.2075
Problem:Error for const argument to mapnew().
Solution:   Don't give an error. (closes #7400)
Files:  src/list.c, src/testdir/test_filter_map.vim


*** ../vim-8.2.2074/src/list.c  2020-11-28 20:32:26.086679786 +0100
--- src/list.c  2020-12-01 21:05:34.618079906 +0100
***
*** 2065,2071 
  
--todo;
di = HI2DI(hi);
!   if (filtermap != FILTERMAP_FILTER
 && (value_check_lock(di->di_tv.v_lock,
   arg_errmsg, TRUE)
|| var_check_ro(di->di_flags,
--- 2065,2071 
  
--todo;
di = HI2DI(hi);
!   if (filtermap == FILTERMAP_MAP
 && (value_check_lock(di->di_tv.v_lock,
   arg_errmsg, TRUE)
|| var_check_ro(di->di_flags,
***
*** 2225,2236 
}
else
{
!   // Materialized list from range(): loop over the items
for (li = l->lv_first; li != NULL; li = nli)
{
typval_T newtv;
  
!   if (filtermap != FILTERMAP_FILTER && value_check_lock(
   li->li_tv.v_lock, arg_errmsg, TRUE))
break;
nli = li->li_next;
--- 2225,2236 
}
else
{
!   // Materialized list: loop over the items
for (li = l->lv_first; li != NULL; li = nli)
{
typval_T newtv;
  
!   if (filtermap == FILTERMAP_MAP && value_check_lock(
   li->li_tv.v_lock, arg_errmsg, TRUE))
break;
nli = li->li_next;
*** ../vim-8.2.2074/src/testdir/test_filter_map.vim 2020-11-09 
18:31:30.548791857 +0100
--- src/testdir/test_filter_map.vim 2020-12-01 21:05:04.838176761 +0100
***
*** 123,128 
--- 123,131 
let dout = mapnew(din, {k, v -> string(v)})
call assert_equal(#{one: 1, two: 2}, din)
call assert_equal(#{one: '1', two: '2'}, dout)
+ 
+   const dconst = #{one: 1, two: 2, three: 3}
+   call assert_equal(#{one: 2, two: 3, three: 4}, mapnew(dconst, {_, v -> v + 
1}))
  endfunc
  
  func Test_mapnew_list()
***
*** 130,135 
--- 133,141 
let lout = mapnew(lin, {k, v -> string(v)})
call assert_equal([1, 2, 3], lin)
call assert_equal(['1', '2', '3'], lout)
+ 
+   const lconst = [1, 2, 3]
+   call assert_equal([2, 3, 4], mapnew(lconst, {_, v -> v + 1}))
  endfunc
  
  func Test_mapnew_blob()
*** ../vim-8.2.2074/src/version.c   2020-12-01 20:12:20.792108768 +0100
--- src/version.c   2020-12-01 21:03:57.186396221 +0100
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 2075,
  /**/

-- 
FATHER:You only killed the bride's father - that's all -
LAUNCELOT: Oh dear, I didn't really mean to...
FATHER:Didn't mean to?  You put your sword right through his head!
LAUNCELOT: Gosh - Is he all right?
 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\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/202012012008.0B1K8fRr3900772%40masaka.moolenaar.net.


Re: Patch 8.2.2071

2020-12-01 Fir de Conversatie Bram Moolenaar


Andy Wokula wrote:

> Am 30.11.2020 um 21:12 schrieb Bram Moolenaar:
> > Problem:Vim9: list assign doesn't except empty remainder list.
> 
> :s/except/accept/

Thanks.

-- 
Trees moving back and forth is what makes the wind blow.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\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/202012011912.0B1JCuev3887436%40masaka.moolenaar.net.


Patch 8.2.2074

2020-12-01 Fir de Conversatie Bram Moolenaar


Patch 8.2.2074
Problem:Vim9: using :normal from Vim9 script can't handle range.
Solution:   Execute a :normal command in legacy script context. (closes #7401)
Files:  src/structs.h, src/ex_docmd.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.2073/src/structs.h   2020-11-15 20:32:54.167882094 +0100
--- src/structs.h   2020-12-01 19:40:47.567677152 +0100
***
*** 4155,4160 
--- 4155,4161 
  int   save_finish_op;
  int   save_opcount;
  int   save_reg_executing;
+ int   save_script_version;
  tasave_T  tabuf;
  } save_state_T;
  
*** ../vim-8.2.2073/src/ex_docmd.c  2020-11-30 21:12:15.747157517 +0100
--- src/ex_docmd.c  2020-12-01 20:09:09.256981924 +0100
***
*** 7994,8003 
  sst->save_finish_op = finish_op;
  sst->save_opcount = opcount;
  sst->save_reg_executing = reg_executing;
  
! msg_scroll = FALSE;   // no msg scrolling in Normal mode
! restart_edit = 0; // don't go to Insert mode
! p_im = FALSE; // don't use 'insertmode'
  
  /*
   * Save the current typeahead.  This is required to allow using ":normal"
--- 7994,8005 
  sst->save_finish_op = finish_op;
  sst->save_opcount = opcount;
  sst->save_reg_executing = reg_executing;
+ sst->save_script_version = current_sctx.sc_version;
  
! msg_scroll = FALSE;   // no msg scrolling in Normal mode
! restart_edit = 0; // don't go to Insert mode
! p_im = FALSE; // don't use 'insertmode'
! current_sctx.sc_version = 1;// not in Vim9 script
  
  /*
   * Save the current typeahead.  This is required to allow using ":normal"
***
*** 8021,8026 
--- 8023,8029 
  opcount = sst->save_opcount;
  reg_executing = sst->save_reg_executing;
  msg_didout |= sst->save_msg_didout;   // don't reset msg_didout now
+ current_sctx.sc_version = sst->save_script_version;
  
  // Restore the state (needed when called from a function executed for
  // 'indentexpr'). Update the mouse and cursor, they may have changed.
*** ../vim-8.2.2073/src/testdir/test_vim9_script.vim2020-12-01 
16:30:40.161598319 +0100
--- src/testdir/test_vim9_script.vim2020-12-01 20:08:19.749218836 +0100
***
*** 2958,2963 
--- 2958,2976 
bwipe!
  enddef
  
+ def InvokeNormal()
+   exe "norm! :m+1\r"
+ enddef
+ 
+ def Test_invoke_normal_in_visual_mode()
+   xnoremap  call InvokeNormal()
+   new
+   setline(1, ['aaa', 'bbb'])
+   feedkeys("V\", 'xt')
+   assert_equal(['bbb', 'aaa'], getline(1, 2))
+   xunmap 
+ enddef
+ 
  " Keep this last, it messes up highlighting.
  def Test_substitute_cmd()
new
*** ../vim-8.2.2073/src/version.c   2020-12-01 16:30:40.165598305 +0100
--- src/version.c   2020-12-01 20:07:21.473504964 +0100
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 2074,
  /**/

-- 
The early bird gets the worm. The second mouse gets the cheese.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\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/202012011912.0B1JCueq3887430%40masaka.moolenaar.net.


Re: Patch 8.2.2071

2020-12-01 Fir de Conversatie 'Andy Wokula' via vim_dev

Am 30.11.2020 um 21:12 schrieb Bram Moolenaar:

Problem:Vim9: list assign doesn't except empty remainder list.


:s/except/accept/

--
Andy

--
--
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/5FC67971.2050601%40yahoo.de.


Patch 8.2.2073

2020-12-01 Fir de Conversatie Bram Moolenaar


Patch 8.2.2073
Problem:Vim9: for with unpack only works for local variables.
Solution:   Recognize different destinations.
Files:  src/vim9compile.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.2072/src/vim9compile.c   2020-11-30 21:39:59.476308440 +0100
--- src/vim9compile.c   2020-12-01 16:02:20.972165341 +0100
***
*** 5066,5071 
--- 5066,5249 
  }
  
  /*
+  * For one assignment figure out the type of destination.  Return it in 
"dest".
+  * When not recognized "dest" is not set.
+  * For an option "opt_flags" is set.
+  * For a v:var "vimvaridx" is set.
+  * "type" is set to the destination type if known, unchanted otherwise.
+  * Return FAIL if an error message was given.
+  */
+ static int
+ get_var_dest(
+   char_u  *name,
+   assign_dest_T   *dest,
+   int cmdidx,
+   int *opt_flags,
+   int *vimvaridx,
+   type_T  **type,
+   cctx_T  *cctx)
+ {
+ char_u *p;
+ 
+ if (*name == '&')
+ {
+   int cc;
+   longnumval;
+   int opt_type;
+ 
+   *dest = dest_option;
+   if (cmdidx == CMD_final || cmdidx == CMD_const)
+   {
+   emsg(_(e_const_option));
+   return FAIL;
+   }
+   p = name;
+   p = find_option_end(&p, opt_flags);
+   if (p == NULL)
+   {
+   // cannot happen?
+   emsg(_(e_letunexp));
+   return FAIL;
+   }
+   cc = *p;
+   *p = NUL;
+   opt_type = get_option_value(skip_option_env_lead(name),
+   &numval, NULL, *opt_flags);
+   *p = cc;
+   if (opt_type == -3)
+   {
+   semsg(_(e_unknown_option), name);
+   return FAIL;
+   }
+   if (opt_type == -2 || opt_type == 0)
+   *type = &t_string;
+   else
+   *type = &t_number;  // both number and boolean option
+ }
+ else if (*name == '$')
+ {
+   *dest = dest_env;
+   *type = &t_string;
+ }
+ else if (*name == '@')
+ {
+   if (!valid_yank_reg(name[1], FALSE) || name[1] == '.')
+   {
+   emsg_invreg(name[1]);
+   return FAIL;
+   }
+   *dest = dest_reg;
+   *type = &t_string;
+ }
+ else if (STRNCMP(name, "g:", 2) == 0)
+ {
+   *dest = dest_global;
+ }
+ else if (STRNCMP(name, "b:", 2) == 0)
+ {
+   *dest = dest_buffer;
+ }
+ else if (STRNCMP(name, "w:", 2) == 0)
+ {
+   *dest = dest_window;
+ }
+ else if (STRNCMP(name, "t:", 2) == 0)
+ {
+   *dest = dest_tab;
+ }
+ else if (STRNCMP(name, "v:", 2) == 0)
+ {
+   typval_T*vtv;
+   int di_flags;
+ 
+   *vimvaridx = find_vim_var(name + 2, &di_flags);
+   if (*vimvaridx < 0)
+   {
+   semsg(_(e_variable_not_found_str), name);
+   return FAIL;
+   }
+   // We use the current value of "sandbox" here, is that OK?
+   if (var_check_ro(di_flags, name, FALSE))
+   return FAIL;
+   *dest = dest_vimvar;
+   vtv = get_vim_var_tv(*vimvaridx);
+   *type = typval2type_vimvar(vtv, cctx->ctx_type_list);
+ }
+ return OK;
+ }
+ 
+ /*
+  * Generate a STORE instruction for "dest", not being "dest_local".
+  * Return FAIL when out of memory.
+  */
+ static int
+ generate_store_var(
+   cctx_T  *cctx,
+   assign_dest_T   dest,
+   int opt_flags,
+   int vimvaridx,
+   int scriptvar_idx,
+   int scriptvar_sid,
+   type_T  *type,
+   char_u  *name)
+ {
+ switch (dest)
+ {
+   case dest_option:
+   return generate_STOREOPT(cctx, skip_option_env_lead(name),
+   opt_flags);
+   case dest_global:
+   // include g: with the name, easier to execute that way
+   return generate_STORE(cctx, ISN_STOREG, 0, name);
+   case dest_buffer:
+   // include b: with the name, easier to execute that way
+   return generate_STORE(cctx, ISN_STOREB, 0, name);
+   case dest_window:
+   // include w: with the name, easier to execute that way
+   return generate_STORE(cctx, ISN_STOREW, 0, name);
+   case dest_tab:
+   // include t: with the name, easier to execute that way
+   return generate_STORE(cctx, ISN_STORET, 0, name);
+   case dest_env:
+   return generate_STORE(cctx, ISN_STOREENV, 0, name + 1);
+   case dest_reg:
+   return generate_STORE(cctx, ISN_STOREREG, name[1], NULL);
+   case dest_vimvar:
+   return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL);
+   case dest_script:
+   if (scriptvar_idx < 0)
+   {
+   char_u  *name_s = name;
+   int r;
+ 
+   // Include s: in the name for store_var(