diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-28 20:40:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-28 20:40:44 +0200 |
commit | 227c58a486d2459e7bf6ed2c917ede7e324e3570 (patch) | |
tree | a434fdecc3b284630170b61d7db110f40772988a /src | |
parent | 03717bf6a27d753fe8f9d713d66594fb1940515f (diff) | |
download | vim-git-227c58a486d2459e7bf6ed2c917ede7e324e3570.tar.gz |
patch 8.2.2817: Vim9: script sourcing continues after an errorv8.2.2817
Problem: Vim9: script sourcing continues after an error.
Solution: Make an error in any command in "vim9script" abort sourcing.
Diffstat (limited to 'src')
-rw-r--r-- | src/ex_docmd.c | 7 | ||||
-rw-r--r-- | src/testdir/test_vim9_assign.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_vim9_func.vim | 6 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 16 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 28 insertions, 7 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 1c41036a4..7811c8f7f 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1175,7 +1175,8 @@ do_cmdline( */ while (!((got_int #ifdef FEAT_EVAL - || (did_emsg && force_abort) || did_throw + || (did_emsg && (force_abort || in_vim9script())) + || did_throw #endif ) #ifdef FEAT_EVAL @@ -1209,8 +1210,10 @@ do_cmdline( /* * If a sourced file or executed function ran to its end, report the * unclosed conditional. + * In Vim9 script do not give a second error, executing aborts after + * the first one. */ - if (!got_int && !did_throw + if (!got_int && !did_throw && !(did_emsg && in_vim9script()) && ((getline_equal(fgetline, cookie, getsourceline) && !source_finished(fgetline, cookie)) || (getline_equal(fgetline, cookie, get_func_line) diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index fbc4d92af..fa418b2ce 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -1768,14 +1768,14 @@ def Test_expr_error_no_assign() var x = 1 / 0 echo x END - CheckScriptFailureList(lines, ['E1154:', 'E121:']) + CheckScriptFailure(lines, 'E1154:') lines =<< trim END vim9script var x = 1 % 0 echo x END - CheckScriptFailureList(lines, ['E1154:', 'E121:']) + CheckScriptFailure(lines, 'E1154:') lines =<< trim END var x: string 'string' diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 5bfad6bcb..4d57eef71 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -2592,6 +2592,7 @@ enddef def Test_nested_lambda_in_closure() var lines =<< trim END vim9script + command WriteDone writefile(['Done'], 'XnestedDone') def Outer() def g:Inner() echo map([1, 2, 3], {_, v -> v + 1}) @@ -2599,10 +2600,9 @@ def Test_nested_lambda_in_closure() g:Inner() enddef defcompile - writefile(['Done'], 'XnestedDone') - quit + # not reached END - if !RunVim([], lines, '--clean') + if !RunVim([], lines, '--clean -c WriteDone -c quit') return endif assert_equal(['Done'], readfile('XnestedDone')) diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 1810c5bc8..0e77b58b6 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -854,6 +854,20 @@ def Test_error_in_nested_function() assert_equal(0, g:test_var) enddef +def Test_abort_after_error() + var lines =<< trim END + vim9script + while true + echo notfound + endwhile + g:gotthere = true + END + g:gotthere = false + CheckScriptFailure(lines, 'E121:') + assert_false(g:gotthere) + unlet g:gotthere +enddef + def Test_cexpr_vimscript() # only checks line continuation set errorformat=File\ %f\ line\ %l @@ -3361,6 +3375,7 @@ def Test_vim9_autoload() return 'test' enddef g:some#name = 'name' + g:some#dict = {key: 'value'} def some#varargs(a1: string, ...l: list<string>): string return a1 .. l[0] .. l[1] @@ -3374,6 +3389,7 @@ def Test_vim9_autoload() assert_equal('test', g:some#gettest()) assert_equal('name', g:some#name) + assert_equal('value', g:some#dict.key) g:some#other = 'other' assert_equal('other', g:some#other) diff --git a/src/version.c b/src/version.c index b1d5be795..0158d8947 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2817, +/**/ 2816, /**/ 2815, |