aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2020-12-02 18:37:18 +0000
committerSean Dewar <seandewar@users.noreply.github.com>2021-09-15 22:30:31 +0100
commitc57132ec2a9c16facff7858c8610c3206398fe7e (patch)
tree922b9534d9798ff4c57417aeeb1f9de4fc82f8e9 /src
parent6a02ccc2226ab427d7e6243a5b6d3e424557b0fd (diff)
downloadrneovim-c57132ec2a9c16facff7858c8610c3206398fe7e.tar.gz
rneovim-c57132ec2a9c16facff7858c8610c3206398fe7e.tar.bz2
rneovim-c57132ec2a9c16facff7858c8610c3206398fe7e.zip
vim-patch:8.1.0793: incorrect error messages for functions that take a Blob
Problem: Incorrect error messages for functions that now take a Blob argument. Solution: Adjust the error messages. (Dominique Pelle, closes vim/vim#3846) https://github.com/vim/vim/commit/0d17f0d1c09fa6db306336695ba646c21ea24909
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/funcs.c13
-rw-r--r--src/nvim/globals.h3
-rw-r--r--src/nvim/testdir/test_blob.vim6
-rw-r--r--src/nvim/testdir/test_listdict.vim4
4 files changed, 17 insertions, 9 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index e804029187..20affdf529 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -96,6 +96,7 @@ PRAGMA_DIAG_POP
static char *e_listarg = N_("E686: Argument of %s must be a List");
+static char *e_listblobarg = N_("E898: Argument of %s must be a List or Blob");
static char *e_invalwindow = N_("E957: Invalid window number");
/// Dummy va_list for passing to vim_snprintf
@@ -334,7 +335,7 @@ static void f_add(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
} else {
- EMSG(_(e_listreq));
+ EMSG(_(e_listblobreq));
}
}
@@ -2884,7 +2885,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
} else {
- EMSG2(_(e_listdictarg), "get()");
+ EMSG2(_(e_listdictblobarg), "get()");
}
if (tv == NULL) {
@@ -4853,7 +4854,7 @@ static void f_index(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
return;
} else if (argvars[0].v_type != VAR_LIST) {
- EMSG(_(e_listreq));
+ EMSG(_(e_listblobreq));
return;
}
list_T *const l = argvars[0].vval.v_list;
@@ -5013,7 +5014,7 @@ static void f_insert(typval_T *argvars, typval_T *rettv, FunPtr fptr)
tv_copy(&argvars[0], rettv);
} else if (argvars[0].v_type != VAR_LIST) {
- EMSG2(_(e_listarg), "insert()");
+ EMSG2(_(e_listblobarg), "insert()");
} else if (!var_check_lock(tv_list_locked((l = argvars[0].vval.v_list)),
N_("insert() argument"), TV_TRANSLATE)) {
long before = 0;
@@ -7349,7 +7350,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
} else if (argvars[0].v_type != VAR_LIST) {
- EMSG2(_(e_listdictarg), "remove()");
+ EMSG2(_(e_listdictblobarg), "remove()");
} else if (!var_check_lock(tv_list_locked((l = argvars[0].vval.v_list)),
arg_errmsg, TV_TRANSLATE)) {
bool error = false;
@@ -7634,7 +7635,7 @@ static void f_reverse(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
tv_blob_set_ret(rettv, b);
} else if (argvars[0].v_type != VAR_LIST) {
- EMSG2(_(e_listarg), "reverse()");
+ EMSG2(_(e_listblobarg), "reverse()");
} else {
list_T *const l = argvars[0].vval.v_list;
if (!var_check_lock(tv_list_locked(l), N_("reverse() argument"),
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 42989ea508..4d54907a75 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -946,8 +946,11 @@ EXTERN char_u e_toomanyarg[] INIT(= N_(
EXTERN char_u e_dictkey[] INIT(= N_(
"E716: Key not present in Dictionary: \"%s\""));
EXTERN char_u e_listreq[] INIT(= N_("E714: List required"));
+EXTERN char_u e_listblobreq[] INIT(= N_("E897: List or Blob required"));
EXTERN char_u e_listdictarg[] INIT(= N_(
"E712: Argument of %s must be a List or Dictionary"));
+EXTERN char_u e_listdictblobarg[] INIT(= N_(
+ "E896: Argument of %s must be a List, Dictionary or Blob"));
EXTERN char_u e_readerrf[] INIT(= N_("E47: Error while reading errorfile"));
EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox"));
EXTERN char_u e_secure[] INIT(= N_("E523: Not allowed here"));
diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim
index dec37f0f10..08342e35d2 100644
--- a/src/nvim/testdir/test_blob.vim
+++ b/src/nvim/testdir/test_blob.vim
@@ -32,6 +32,7 @@ func Test_blob_create()
call assert_fails('let b = 0z1.1')
call assert_fails('let b = 0z.')
call assert_fails('let b = 0z001122.')
+ call assert_fails('call get("", 1)', 'E896:')
endfunc
" assignment to a blob
@@ -182,6 +183,7 @@ func Test_blob_add()
call assert_equal(0z00112233, b)
call assert_fails('call add(b, [9])', 'E745:')
+ call assert_fails('call add("", 0x01)', 'E897:')
endfunc
func Test_blob_empty()
@@ -219,7 +221,7 @@ func Test_blob_func_remove()
call assert_fails("call remove(b, 5)", 'E979:')
call assert_fails("call remove(b, 1, 5)", 'E979:')
call assert_fails("call remove(b, 3, 2)", 'E979:')
- call assert_fails("call remove(1, 0)", 'E712:')
+ call assert_fails("call remove(1, 0)", 'E896:')
call assert_fails("call remove(b, b)", 'E974:')
endfunc
@@ -255,7 +257,7 @@ func Test_blob_index()
call assert_equal(2, index(0z11111111, 0x11, -2))
call assert_equal(3, index(0z11110111, 0x11, -2))
- call assert_fails('call index("asdf", 0)', 'E714:')
+ call assert_fails('call index("asdf", 0)', 'E897:')
endfunc
func Test_blob_insert()
diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim
index 5152af8f58..fa711dde2d 100644
--- a/src/nvim/testdir/test_listdict.vim
+++ b/src/nvim/testdir/test_listdict.vim
@@ -139,7 +139,7 @@ func Test_list_func_remove()
call assert_fails("call remove(l, 5)", 'E684:')
call assert_fails("call remove(l, 1, 5)", 'E684:')
call assert_fails("call remove(l, 3, 2)", 'E16:')
- call assert_fails("call remove(1, 0)", 'E712:')
+ call assert_fails("call remove(1, 0)", 'E896:')
call assert_fails("call remove(l, l)", 'E745:')
endfunc
@@ -616,6 +616,8 @@ func Test_reverse_sort_uniq()
call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 1))
call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i'))
call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l)))
+
+ call assert_fails('call reverse("")', 'E898:')
endfunc
" splitting a string to a List