Patch 8.2.2817
Problem: Vim9: script sourcing continues after an error.
Solution: Make an error in any command in "vim9script" abort sourcing.
Files: src/ex_docmd.c, src/testdir/test_vim9_script.vim,
src/testdir/test_vim9_assign.vim,
src/testdir/test_vim9_func.vim
*** ../vim-8.2.2816/src/ex_docmd.c 2021-04-25 16:35:52.101622736 +0200
--- src/ex_docmd.c 2021-04-28 20:25:23.897984495 +0200
***************
*** 1175,1181 ****
*/
while (!((got_int
#ifdef FEAT_EVAL
! || (did_emsg && force_abort) || did_throw
#endif
)
#ifdef FEAT_EVAL
--- 1175,1182 ----
*/
while (!((got_int
#ifdef FEAT_EVAL
! || (did_emsg && (force_abort || in_vim9script()))
! || did_throw
#endif
)
#ifdef FEAT_EVAL
***************
*** 1209,1216 ****
/*
* If a sourced file or executed function ran to its end, report the
* unclosed conditional.
*/
! if (!got_int && !did_throw
&& ((getline_equal(fgetline, cookie, getsourceline)
&& !source_finished(fgetline, cookie))
|| (getline_equal(fgetline, cookie, get_func_line)
--- 1210,1219 ----
/*
* 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 && !(did_emsg && in_vim9script())
&& ((getline_equal(fgetline, cookie, getsourceline)
&& !source_finished(fgetline, cookie))
|| (getline_equal(fgetline, cookie, get_func_line)
*** ../vim-8.2.2816/src/testdir/test_vim9_script.vim 2021-04-17 17:59:15.823846287 +0200
--- src/testdir/test_vim9_script.vim 2021-04-28 20:22:19.542243699 +0200
***************
*** 854,859 ****
--- 854,873 ----
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,3366 ****
--- 3375,3381 ----
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,3379 ****
--- 3389,3395 ----
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)
*** ../vim-8.2.2816/src/testdir/test_vim9_assign.vim 2021-04-24 20:43:52.591422131 +0200
--- src/testdir/test_vim9_assign.vim 2021-04-28 20:13:48.939807642 +0200
***************
*** 1768,1781 ****
var x = 1 / 0
echo x
END
! CheckScriptFailureList(lines, ['E1154:', 'E121:'])
lines =<< trim END
vim9script
var x = 1 % 0
echo x
END
! CheckScriptFailureList(lines, ['E1154:', 'E121:'])
lines =<< trim END
var x: string 'string'
--- 1768,1781 ----
var x = 1 / 0
echo x
END
! CheckScriptFailure(lines, 'E1154:')
lines =<< trim END
vim9script
var x = 1 % 0
echo x
END
! CheckScriptFailure(lines, 'E1154:')
lines =<< trim END
var x: string 'string'
*** ../vim-8.2.2816/src/testdir/test_vim9_func.vim 2021-04-25 13:54:38.992836747 +0200
--- src/testdir/test_vim9_func.vim 2021-04-28 20:33:10.281009849 +0200
***************
*** 2592,2597 ****
--- 2592,2598 ----
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,2608 ****
g:Inner()
enddef
defcompile
! writefile(['Done'], 'XnestedDone')
! quit
END
! if !RunVim([], lines, '--clean')
return
endif
assert_equal(['Done'], readfile('XnestedDone'))
--- 2600,2608 ----
g:Inner()
enddef
defcompile
! # not reached
END
! if !RunVim([], lines, '--clean -c WriteDone -c quit')
return
endif
assert_equal(['Done'], readfile('XnestedDone'))
*** ../vim-8.2.2816/src/version.c 2021-04-28 20:00:35.014355562 +0200
--- src/version.c 2021-04-28 20:40:22.479899191 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2817,
/**/
--
I'm in shape. Round IS a shape.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///