mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.2817: Vim9: script sourcing continues after an error
Problem: Vim9: script sourcing continues after an error. Solution: Make an error in any command in "vim9script" abort sourcing.
This commit is contained in:
@@ -1175,7 +1175,8 @@ do_cmdline(
|
|||||||
*/
|
*/
|
||||||
while (!((got_int
|
while (!((got_int
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
|| (did_emsg && force_abort) || did_throw
|
|| (did_emsg && (force_abort || in_vim9script()))
|
||||||
|
|| did_throw
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
@@ -1209,8 +1210,10 @@ do_cmdline(
|
|||||||
/*
|
/*
|
||||||
* If a sourced file or executed function ran to its end, report the
|
* If a sourced file or executed function ran to its end, report the
|
||||||
* unclosed conditional.
|
* 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)
|
&& ((getline_equal(fgetline, cookie, getsourceline)
|
||||||
&& !source_finished(fgetline, cookie))
|
&& !source_finished(fgetline, cookie))
|
||||||
|| (getline_equal(fgetline, cookie, get_func_line)
|
|| (getline_equal(fgetline, cookie, get_func_line)
|
||||||
|
@@ -1768,14 +1768,14 @@ def Test_expr_error_no_assign()
|
|||||||
var x = 1 / 0
|
var x = 1 / 0
|
||||||
echo x
|
echo x
|
||||||
END
|
END
|
||||||
CheckScriptFailureList(lines, ['E1154:', 'E121:'])
|
CheckScriptFailure(lines, 'E1154:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
var x = 1 % 0
|
var x = 1 % 0
|
||||||
echo x
|
echo x
|
||||||
END
|
END
|
||||||
CheckScriptFailureList(lines, ['E1154:', 'E121:'])
|
CheckScriptFailure(lines, 'E1154:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var x: string 'string'
|
var x: string 'string'
|
||||||
|
@@ -2592,6 +2592,7 @@ enddef
|
|||||||
def Test_nested_lambda_in_closure()
|
def Test_nested_lambda_in_closure()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
command WriteDone writefile(['Done'], 'XnestedDone')
|
||||||
def Outer()
|
def Outer()
|
||||||
def g:Inner()
|
def g:Inner()
|
||||||
echo map([1, 2, 3], {_, v -> v + 1})
|
echo map([1, 2, 3], {_, v -> v + 1})
|
||||||
@@ -2599,10 +2600,9 @@ def Test_nested_lambda_in_closure()
|
|||||||
g:Inner()
|
g:Inner()
|
||||||
enddef
|
enddef
|
||||||
defcompile
|
defcompile
|
||||||
writefile(['Done'], 'XnestedDone')
|
# not reached
|
||||||
quit
|
|
||||||
END
|
END
|
||||||
if !RunVim([], lines, '--clean')
|
if !RunVim([], lines, '--clean -c WriteDone -c quit')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
assert_equal(['Done'], readfile('XnestedDone'))
|
assert_equal(['Done'], readfile('XnestedDone'))
|
||||||
|
@@ -854,6 +854,20 @@ def Test_error_in_nested_function()
|
|||||||
assert_equal(0, g:test_var)
|
assert_equal(0, g:test_var)
|
||||||
enddef
|
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()
|
def Test_cexpr_vimscript()
|
||||||
# only checks line continuation
|
# only checks line continuation
|
||||||
set errorformat=File\ %f\ line\ %l
|
set errorformat=File\ %f\ line\ %l
|
||||||
@@ -3361,6 +3375,7 @@ def Test_vim9_autoload()
|
|||||||
return 'test'
|
return 'test'
|
||||||
enddef
|
enddef
|
||||||
g:some#name = 'name'
|
g:some#name = 'name'
|
||||||
|
g:some#dict = {key: 'value'}
|
||||||
|
|
||||||
def some#varargs(a1: string, ...l: list<string>): string
|
def some#varargs(a1: string, ...l: list<string>): string
|
||||||
return a1 .. l[0] .. l[1]
|
return a1 .. l[0] .. l[1]
|
||||||
@@ -3374,6 +3389,7 @@ def Test_vim9_autoload()
|
|||||||
|
|
||||||
assert_equal('test', g:some#gettest())
|
assert_equal('test', g:some#gettest())
|
||||||
assert_equal('name', g:some#name)
|
assert_equal('name', g:some#name)
|
||||||
|
assert_equal('value', g:some#dict.key)
|
||||||
g:some#other = 'other'
|
g:some#other = 'other'
|
||||||
assert_equal('other', g:some#other)
|
assert_equal('other', g:some#other)
|
||||||
|
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2817,
|
||||||
/**/
|
/**/
|
||||||
2816,
|
2816,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user