Problem: Vim9: script sourcing continues after an error.
Solution: Make an error in any command in "vim9script" abort sourcing.
*/
while (!((got_int
#ifdef FEAT_EVAL
- || (did_emsg && force_abort) || did_throw
+ || (did_emsg && (force_abort || in_vim9script()))
+ || did_throw
#endif
)
#ifdef FEAT_EVAL
/*
* 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)
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'
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})
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'))
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
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]
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)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2817,
/**/
2816,
/**/