Patch 9.0.0432
Problem: Crash when using for loop variable in closure.
Solution: Check that the variable wasn't deleted. (issue #11094)
Files: src/vim9execute.c, src/errors.h, src/testdir/test_vim9_func.vim,
src/testdir/dumps/Test_vim9_closure_fails.dump
*** ../vim-9.0.0431/src/vim9execute.c 2022-09-07 16:48:41.183678514 +0100
--- src/vim9execute.c 2022-09-09 21:17:28.400354076 +0100
***************
*** 1716,1721 ****
--- 1716,1727 ----
return NULL;
}
sv = ((svar_T *)si->sn_var_vals.ga_data) + sref->sref_idx;
+ if (sv->sv_name == NULL)
+ {
+ if (dfunc != NULL)
+ emsg(_(e_script_variable_was_deleted));
+ return NULL;
+ }
if (!equal_type(sv->sv_type, sref->sref_type, 0))
{
if (dfunc != NULL)
*** ../vim-9.0.0431/src/errors.h 2022-09-09 18:46:41.558660414 +0100
--- src/errors.h 2022-09-09 21:16:19.652404493 +0100
***************
*** 3331,3334 ****
--- 3331,3336 ----
INIT(= N_("E1300: Cannot use a partial with dictionary for :defer"));
EXTERN char e_string_number_list_or_blob_required_for_argument_nr[]
INIT(= N_("E1301: String, Number, List or Blob required for argument
%d"));
+ EXTERN char e_script_variable_was_deleted[]
+ INIT(= N_("E1302: Script variable was deleted"));
#endif
*** ../vim-9.0.0431/src/testdir/test_vim9_func.vim 2022-09-09
18:46:41.558660414 +0100
--- src/testdir/test_vim9_func.vim 2022-09-09 21:27:09.395753321 +0100
***************
*** 2943,2948 ****
--- 2943,2972 ----
v9.CheckScriptFailure(lines, 'E1012:')
enddef
+ def Run_Test_closure_in_for_loop_fails()
+ var lines =<< trim END
+ vim9script
+ for n in [0]
+ timer_start(10, (_) => {
+ echo n
+ })
+ endfor
+ END
+ writefile(lines, 'XTest_closure_fails', 'D')
+
+ # Check that an error shows
+ var buf = g:RunVimInTerminal('-S XTest_closure_fails', {'rows': 6})
+ g:VerifyScreenDump(buf, 'Test_vim9_closure_fails', {})
+
+ # clean up
+ g:StopVimInTerminal(buf)
+ enddef
+
+ func Test_closure_in_for_loop_fails()
+ CheckScreendump
+ call Run_Test_closure_in_for_loop_fails()
+ endfunc
+
def Test_global_closure()
var lines =<< trim END
vim9script
***************
*** 3321,3327 ****
enddef
defcompile
END
! writefile(lines, 'XTest_silent_echo')
# Check that the balloon shows up after a mouse move
var buf = g:RunVimInTerminal('-S XTest_silent_echo', {'rows': 6})
--- 3345,3351 ----
enddef
defcompile
END
! writefile(lines, 'XTest_silent_echo', 'D')
# Check that the balloon shows up after a mouse move
var buf = g:RunVimInTerminal('-S XTest_silent_echo', {'rows': 6})
***************
*** 3330,3336 ****
# clean up
g:StopVimInTerminal(buf)
- delete('XTest_silent_echo')
enddef
def SilentlyError()
--- 3354,3359 ----
*** ../vim-9.0.0431/src/testdir/dumps/Test_vim9_closure_fails.dump
2022-09-09 21:32:59.631309912 +0100
--- src/testdir/dumps/Test_vim9_closure_fails.dump 2022-09-09
21:27:15.259746224 +0100
***************
*** 0 ****
--- 1,6 ----
+ |~+0#4040ff13#ffffff0| @73
+ |~| @73
+ |E+0#ffffff16#e000002|r@1|o|r| |d|e|t|e|c|t|e|d| |w|h|i|l|e|
|p|r|o|c|e|s@1|i|n|g| |f|u|n|c|t|i|o|n| |<|l|a|m|b|d|a|>|1|:|
+0#0000000#ffffff0@23
+ |l+0#af5f00255&|i|n|e| @3|1|:| +0#0000000&@64
+ |E+0#ffffff16#e000002|1|3|0|2|:| |S|c|r|i|p|t| |v|a|r|i|a|b|l|e| |w|a|s|
|d|e|l|e|t|e|d| +0#0000000#ffffff0@40
+ |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-9.0.0431/src/version.c 2022-09-09 20:19:19.548094855 +0100
--- src/version.c 2022-09-09 21:28:27.743657361 +0100
***************
*** 705,706 ****
--- 705,708 ----
{ /* Add new patch number below this line */
+ /**/
+ 432,
/**/
--
hundred-and-one symptoms of being an internet addict:
35. Your husband tells you he's had that beard for 2 months.
/// 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/20220909203604.D3E5B1C0CF3%40moolenaar.net.