summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-17 21:29:03 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-17 21:29:03 +0200
commit77e5dcc36a82da040072d74e3ced410d15c42757 (patch)
tree00e7367a7cb2433b07a72fa976e0c528c7f77fe0 /src/testdir
parent213da551dec465e193619684b260bf9d5a8d6afc (diff)
downloadvim-git-77e5dcc36a82da040072d74e3ced410d15c42757.tar.gz
patch 8.2.1704: Vim9: crash in for loop when autoload script has an errorv8.2.1704
Problem: Vim9: crash in for loop when autoload script has an error. Solution: Reset suppress_errthrow. Check for NULL list. (closes #6967)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_vim9_script.vim39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 2f1e708f2..42eaab0ad 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -3353,6 +3353,45 @@ def Test_vim9_autoload()
&rtp = save_rtp
enddef
+" This was causing a crash because suppress_errthrow wasn't reset.
+def Test_vim9_autoload_error()
+ let lines =<< trim END
+ vim9script
+ def crash#func()
+ try
+ for x in List()
+ endfor
+ catch
+ endtry
+ g:ok = true
+ enddef
+ fu List()
+ invalid
+ endfu
+ try
+ invalid
+ catch /wontmatch/
+ endtry
+ END
+ call mkdir('Xruntime/autoload', 'p')
+ call writefile(lines, 'Xruntime/autoload/crash.vim')
+
+ # run in a separate Vim to avoid the side effects of assert_fails()
+ lines =<< trim END
+ exe 'set rtp^=' .. getcwd() .. '/Xruntime'
+ call crash#func()
+ call writefile(['ok'], 'Xdidit')
+ qall
+ END
+ writefile(lines, 'Xscript')
+ RunVim([], [], '-S Xscript')
+ assert_equal(['ok'], readfile('Xdidit'))
+
+ delete('Xdidit')
+ delete('Xscript')
+ delete('Xruntime', 'rf')
+enddef
+
def Test_script_var_in_autocmd()
# using a script variable from an autocommand, defined in a :def function in a
# legacy Vim script, cannot check the variable type.