aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-15 14:11:10 +0800
committerGitHub <noreply@github.com>2023-04-15 14:11:10 +0800
commit1ca77c222b00215657bae416eba5d280a1d9dc29 (patch)
tree2d203ebcd6609c1db6c61cde4d43fccb7424f341 /src
parentc2e47e7bec0394a2cc12c8f83e3e5950ad99d1b4 (diff)
parent85741677c86f7686e3597a310f8059608e7816fb (diff)
downloadrneovim-1ca77c222b00215657bae416eba5d280a1d9dc29.tar.gz
rneovim-1ca77c222b00215657bae416eba5d280a1d9dc29.tar.bz2
rneovim-1ca77c222b00215657bae416eba5d280a1d9dc29.zip
Merge pull request #23097 from zeertzjq/vim-8.2.0101
vim-patch:8.2.{0101,0102,0103,0104,0633,0634}: null typval tests
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c13
-rw-r--r--src/nvim/eval/typval.c2
-rw-r--r--src/nvim/globals.h1
3 files changed, 12 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 6a8b24ceed..f555d973e4 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -789,6 +789,9 @@ int eval_expr_typval(const typval_T *expr, typval_T *argv, int argc, typval_T *r
}
} else if (expr->v_type == VAR_PARTIAL) {
partial_T *const partial = expr->vval.v_partial;
+ if (partial == NULL) {
+ return FAIL;
+ }
const char *const s = partial_name(partial);
if (s == NULL || *s == NUL) {
return FAIL;
@@ -4056,7 +4059,10 @@ char *partial_name(partial_T *pt)
if (pt->pt_name != NULL) {
return pt->pt_name;
}
- return pt->pt_func->uf_name;
+ if (pt->pt_func != NULL) {
+ return pt->pt_func->uf_name;
+ }
+ return "";
}
static void partial_free(partial_T *pt)
@@ -8640,8 +8646,9 @@ int typval_compare(typval_T *typ1, typval_T *typ2, exprtype_T type, bool ic)
}
if ((typ1->v_type == VAR_PARTIAL && typ1->vval.v_partial == NULL)
|| (typ2->v_type == VAR_PARTIAL && typ2->vval.v_partial == NULL)) {
- // when a partial is NULL assume not equal
- n1 = false;
+ // When both partials are NULL, then they are equal.
+ // Otherwise they are not equal.
+ n1 = (typ1->vval.v_partial == typ2->vval.v_partial);
} else if (type_is) {
if (typ1->v_type == VAR_FUNC && typ2->v_type == VAR_FUNC) {
// strings are considered the same if their value is
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 91be41751e..7c982de61e 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -3806,7 +3806,7 @@ static const char *const str_errors[] = {
[VAR_DICT]= N_("E731: using Dictionary as a String"),
[VAR_FLOAT]= e_float_as_string,
[VAR_BLOB]= N_("E976: using Blob as a String"),
- [VAR_UNKNOWN]= N_("E908: using an invalid value as a String"),
+ [VAR_UNKNOWN]= e_inval_string,
};
#undef FUNC_ERROR
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 7653076e39..e406d93494 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -998,6 +998,7 @@ EXTERN const char e_listarg[] INIT(= N_("E686: Argument of %s must be a List"));
EXTERN const char e_unsupportedoption[] INIT(= N_("E519: Option not supported"));
EXTERN const char e_fnametoolong[] INIT(= N_("E856: Filename too long"));
EXTERN const char e_float_as_string[] INIT(= N_("E806: using Float as a String"));
+EXTERN const char e_inval_string[] INIT(= N_("E908: using an invalid value as a String"));
EXTERN const char e_cannot_edit_other_buf[] INIT(= N_("E788: Not allowed to edit another buffer now"));
EXTERN const char e_cmdmap_err[] INIT(= N_("E5520: <Cmd> mapping must end with <CR>"));