diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-12 18:46:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-12 18:46:35 +0800 |
commit | 758c418d1261fd69c4a85aa5cfa6a0d1dcdf66a4 (patch) | |
tree | a84e22da245c35628d04b9cfcf0849077703a067 | |
parent | b867f6c7c5cadd2bd09443a74a84aa55eb819e58 (diff) | |
parent | aa7c4b88dc30cfe53a7c9bee6e49ad5b6bbca090 (diff) | |
download | rneovim-758c418d1261fd69c4a85aa5cfa6a0d1dcdf66a4.tar.gz rneovim-758c418d1261fd69c4a85aa5cfa6a0d1dcdf66a4.tar.bz2 rneovim-758c418d1261fd69c4a85aa5cfa6a0d1dcdf66a4.zip |
Merge pull request #23998 from zeertzjq/vim-8.2.3852
vim-patch:8.2.{3852,3853}
-rw-r--r-- | src/nvim/eval.c | 15 | ||||
-rw-r--r-- | test/old/testdir/test_listdict.vim | 40 |
2 files changed, 32 insertions, 23 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 50da0a8657..b2729b0e67 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -89,20 +89,25 @@ static const char *e_missbrac = N_("E111: Missing ']'"); static const char *e_list_end = N_("E697: Missing end of List ']': %s"); -static const char *e_cannot_slice_dictionary +static const char e_cannot_slice_dictionary[] = N_("E719: Cannot slice a Dictionary"); static const char e_cannot_index_special_variable[] = N_("E909: Cannot index a special variable"); static const char *e_nowhitespace = N_("E274: No white space allowed before parenthesis"); static const char *e_write2 = N_("E80: Error while writing: %s"); +static const char e_cannot_index_a_funcref[] + = N_("E695: Cannot index a Funcref"); static const char e_variable_nested_too_deep_for_making_copy[] = N_("E698: Variable nested too deep for making a copy"); -static const char *e_string_list_or_blob_required = N_("E1098: String, List or Blob required"); -static const char e_expression_too_recursive_str[] = N_("E1169: Expression too recursive: %s"); +static const char e_string_list_or_blob_required[] + = N_("E1098: String, List or Blob required"); +static const char e_expression_too_recursive_str[] + = N_("E1169: Expression too recursive: %s"); static const char e_dot_can_only_be_used_on_dictionary_str[] = N_("E1203: Dot can only be used on a dictionary: %s"); -static const char e_empty_function_name[] = N_("E1192: Empty function name"); +static const char e_empty_function_name[] + = N_("E1192: Empty function name"); static char * const namespace_char = "abglstvw"; @@ -3567,7 +3572,7 @@ static int check_can_index(typval_T *rettv, bool evaluate, bool verbose) case VAR_FUNC: case VAR_PARTIAL: if (verbose) { - emsg(_("E695: Cannot index a Funcref")); + emsg(_(e_cannot_index_a_funcref)); } return FAIL; case VAR_FLOAT: diff --git a/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim index 4ed3991ee7..07a365d337 100644 --- a/test/old/testdir/test_listdict.vim +++ b/test/old/testdir/test_listdict.vim @@ -1178,26 +1178,30 @@ endfunc " List and dict indexing tests func Test_listdict_index() - call assert_fails('echo function("min")[0]', 'E695:') - call assert_fails('echo v:true[0]', 'E909:') - let d = {'k' : 10} - call assert_fails('echo d.', 'E15:') - call assert_fails('echo d[1:2]', 'E719:') + call CheckLegacyAndVim9Failure(['echo function("min")[0]'], 'E695:') + call CheckLegacyAndVim9Failure(['echo v:true[0]'], 'E909:') + call CheckLegacyAndVim9Failure(['echo v:null[0]'], 'E909:') + call CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d.'], ['E15:', 'E1127:', 'E15:']) + call CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d[1 : 2]'], 'E719:') + call assert_fails("let v = [4, 6][{-> 1}]", 'E729:') - call assert_fails("let v = range(5)[2:[]]", 'E730:') + call CheckDefAndScriptFailure(['var v = [4, 6][() => 1]'], ['E1012', 'E703:']) + + call CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : []]'], ['E730:', 'E1012:', 'E730:']) + call assert_fails("let v = range(5)[2:{-> 2}(]", ['E15:', 'E116:']) - call assert_fails("let v = range(5)[2:3", 'E111:') - call assert_fails("let l = insert([1,2,3], 4, 10)", 'E684:') - call assert_fails("let l = insert([1,2,3], 4, -10)", 'E684:') - call assert_fails("let l = insert([1,2,3], 4, [])", 'E745:') - let l = [1, 2, 3] - call assert_fails("let l[i] = 3", 'E121:') - call assert_fails("let l[1.1] = 4", 'E805:') - call assert_fails("let l[:i] = [4, 5]", 'E121:') - call assert_fails("let l[:3.2] = [4, 5]", 'E805:') - " Nvim doesn't have test_unknown() - " let t = test_unknown() - " call assert_fails("echo t[0]", 'E685:') + call CheckDefAndScriptFailure(['var v = range(5)[2 : () => 2(]'], 'E15:') + + call CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : 3'], ['E111:', 'E1097:', 'E111:']) + call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, 10)'], 'E684:') + call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, -10)'], 'E684:') + call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, [])'], ['E745:', 'E1013:', 'E1210:']) + + call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[i] = 3'], ['E121:', 'E1001:', 'E121:']) + call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[1.1] = 4'], ['E805:', 'E1012:', 'E805:']) + call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: i] = [4, 5]'], ['E121:', 'E1001:', 'E121:']) + call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: 3.2] = [4, 5]'], ['E805:', 'E1012:', 'E805:']) + " call CheckLegacyAndVim9Failure(['VAR t = test_unknown()', 'echo t[0]'], 'E685:') endfunc " Test for a null list |