# HG changeset patch # User Bram Moolenaar # Date 1644960604 -3600 # Node ID d754ac2f5ac5f66364eded7b6e33c141cc788d86 # Parent 9e05a238b0f072474329dc1d491e2496a5206d87 patch 8.2.4395: some code lines not covered by tests Commit: https://github.com/vim/vim/commit/8b716f5f2204f938769de283d43bcb2f77d403e7 Author: Bram Moolenaar Date: Tue Feb 15 21:17:56 2022 +0000 patch 8.2.4395: some code lines not covered by tests Problem: Some code lines not covered by tests. Solution: Add a few more test cases. Fix getting more than one error for invalid assignment. diff --git a/src/errors.h b/src/errors.h --- a/src/errors.h +++ b/src/errors.h @@ -2788,7 +2788,8 @@ EXTERN char e_missing_argument_type_for_ INIT(= N_("E1077: Missing argument type for %s")); // E1078 unused // E1079 unused -// E1080 unused +EXTERN char e_invalid_assignment[] + INIT(= N_("E1080: Invalid assignment")); EXTERN char e_cannot_unlet_str[] INIT(= N_("E1081: Cannot unlet %s")); #endif diff --git a/src/evalvars.c b/src/evalvars.c --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1107,7 +1107,8 @@ skip_var_list( { if (*semicolon == 1) { - emsg(_(e_double_semicolon_in_list_of_variables)); + if (!silent) + emsg(_(e_double_semicolon_in_list_of_variables)); return NULL; } *semicolon = 1; diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -1359,7 +1359,8 @@ def Test_assignment_failure() v9.CheckDefFailure(['var null = 1'], 'E1034:') v9.CheckDefFailure(['var this = 1'], 'E1034:') - v9.CheckDefFailure(['[a; b; c] = g:list'], 'E452:') + v9.CheckDefFailure(['[a; b; c] = g:list'], 'E1001:') + v9.CheckDefFailure(['var [a; b; c] = g:list'], 'E1080:') v9.CheckDefExecFailure(['var a: number', '[a] = test_null_list()'], 'E1093:') v9.CheckDefExecFailure(['var a: number', diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1355,6 +1355,13 @@ def Test_command_not_recognized() v9.CheckDefFailure(lines, 'E1146:', 1) lines =<< trim END + if 0 + d.key = 'asdf' + endif + END + v9.CheckDefSuccess(lines) + + lines =<< trim END d['key'] = 'asdf' END v9.CheckDefFailure(lines, 'E1146:', 1) @@ -1621,6 +1628,11 @@ def Test_substitute_expr() s/text/\=['aaa', 'bbb', 'ccc']/ assert_equal(['some aaa', 'bbb', 'ccc', ' here'], getline(1, '$')) bwipe! + + # inside "if 0" substitute is ignored + if 0 + s/a/\=nothing/ and | some more + endif enddef def Test_redir_to_var() @@ -1664,6 +1676,12 @@ def Test_redir_to_var() v9.CheckDefFailure(lines, 'E1089:') lines =<< trim END + var text: string + redir => text + END + v9.CheckDefFailure(lines, 'E1185:') + + lines =<< trim END var ls = 'asdf' redir => ls[1] redir END diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -3762,7 +3762,15 @@ def Test_go_beyond_end_of_cmd() v9.CheckScriptFailure(lines, 'E476:') enddef +" The following messes up syntax highlight, keep near the end. if has('python3') + def Test_python3_command() + py3 import vim + py3 vim.command("let g:done = 'yes'") + assert_equal('yes', g:done) + unlet g:done + enddef + def Test_python3_heredoc() py3 << trim EOF import vim @@ -3778,7 +3786,6 @@ if has('python3') enddef endif -" This messes up syntax highlight, keep near the end. if has('lua') def Test_lua_heredoc() g:d = {} diff --git a/src/version.c b/src/version.c --- 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 */ /**/ + 4395, +/**/ 4394, /**/ 4393, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2420,7 +2420,7 @@ may_compile_assignment(exarg_T *eap, cha if (*eap->cmd == '[') { - // [var, var] = expr + // might be "[var, var] = expr" *line = compile_assignment(eap->cmd, eap, CMD_SIZE, cctx); if (*line == NULL) return FAIL; @@ -2958,7 +2958,10 @@ compile_def_function( case CMD_decrement: line = compile_assignment(p, &ea, ea.cmdidx, &cctx); if (line == p) + { + emsg(_(e_invalid_assignment)); line = NULL; + } break; case CMD_unlet: