mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
eval: Port parts of 7.4.1267 that are not already present
This commit is contained in:
@@ -99,6 +99,8 @@ are always available and may be used simultaneously in separate plugins. The
|
|||||||
error out.
|
error out.
|
||||||
4. Stringifyed infinite and NaN values now use |str2float()| and can be evaled
|
4. Stringifyed infinite and NaN values now use |str2float()| and can be evaled
|
||||||
back.
|
back.
|
||||||
|
5. (internal) Trying to print or stringify VAR_UNKNOWN in Vim results in
|
||||||
|
nothing, |E908|, in Neovim it is internal error.
|
||||||
|
|
||||||
|jsondecode()| behaviour changed:
|
|jsondecode()| behaviour changed:
|
||||||
1. It may output |msgpack-special-dict|.
|
1. It may output |msgpack-special-dict|.
|
||||||
|
@@ -4319,19 +4319,37 @@ eval_index (
|
|||||||
char_u *s;
|
char_u *s;
|
||||||
char_u *key = NULL;
|
char_u *key = NULL;
|
||||||
|
|
||||||
if (rettv->v_type == VAR_FUNC) {
|
switch (rettv->v_type) {
|
||||||
if (verbose)
|
case VAR_FUNC: {
|
||||||
EMSG(_("E695: Cannot index a Funcref"));
|
if (verbose) {
|
||||||
return FAIL;
|
EMSG(_("E695: Cannot index a Funcref"));
|
||||||
} else if (rettv->v_type == VAR_FLOAT) {
|
}
|
||||||
if (verbose)
|
return FAIL;
|
||||||
EMSG(_(e_float_as_string));
|
}
|
||||||
return FAIL;
|
case VAR_FLOAT: {
|
||||||
} else if (rettv->v_type == VAR_SPECIAL) {
|
if (verbose) {
|
||||||
if (verbose) {
|
EMSG(_(e_float_as_string));
|
||||||
EMSG(_("E15: Cannot index a special value"));
|
}
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
case VAR_SPECIAL: {
|
||||||
|
if (verbose) {
|
||||||
|
EMSG(_("E909: Cannot index a special variable"));
|
||||||
|
}
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
case VAR_UNKNOWN: {
|
||||||
|
if (evaluate) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
// fallthrough
|
||||||
|
}
|
||||||
|
case VAR_STRING:
|
||||||
|
case VAR_NUMBER:
|
||||||
|
case VAR_LIST:
|
||||||
|
case VAR_DICT: {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init_tv(&var1);
|
init_tv(&var1);
|
||||||
@@ -4522,11 +4540,11 @@ eval_index (
|
|||||||
*rettv = var1;
|
*rettv = var1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case VAR_SPECIAL:
|
||||||
case VAR_FUNC:
|
case VAR_FUNC:
|
||||||
case VAR_FLOAT:
|
case VAR_FLOAT:
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
case VAR_SPECIAL:
|
break; // Not evaluating, skipping over subscript
|
||||||
assert(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5076,11 +5094,12 @@ tv_equal (
|
|||||||
return tv1->vval.v_special == tv2->vval.v_special;
|
return tv1->vval.v_special == tv2->vval.v_special;
|
||||||
|
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
break;
|
// VAR_UNKNOWN can be the result of an invalid expression, let’s say it does
|
||||||
|
// not equal anything, not even self.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EMSG2(_(e_intern2), "tv_equal()");
|
assert(false);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -8516,7 +8535,7 @@ static void f_diff_hlID(typval_T *argvars, typval_T *rettv)
|
|||||||
*/
|
*/
|
||||||
static void f_empty(typval_T *argvars, typval_T *rettv)
|
static void f_empty(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
int n;
|
bool n;
|
||||||
|
|
||||||
switch (argvars[0].v_type) {
|
switch (argvars[0].v_type) {
|
||||||
case VAR_STRING:
|
case VAR_STRING:
|
||||||
@@ -8542,8 +8561,9 @@ static void f_empty(typval_T *argvars, typval_T *rettv)
|
|||||||
n = argvars[0].vval.v_special != kSpecialVarTrue;
|
n = argvars[0].vval.v_special != kSpecialVarTrue;
|
||||||
break;
|
break;
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
EMSG2(_(e_intern2), "f_empty()");
|
EMSG2(_(e_intern2), "f_empty(UNKNOWN)");
|
||||||
n = 0;
|
n = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rettv->vval.v_number = n;
|
rettv->vval.v_number = n;
|
||||||
@@ -11641,7 +11661,10 @@ static void f_len(typval_T *argvars, typval_T *rettv)
|
|||||||
case VAR_DICT:
|
case VAR_DICT:
|
||||||
rettv->vval.v_number = dict_len(argvars[0].vval.v_dict);
|
rettv->vval.v_number = dict_len(argvars[0].vval.v_dict);
|
||||||
break;
|
break;
|
||||||
default:
|
case VAR_UNKNOWN:
|
||||||
|
case VAR_SPECIAL:
|
||||||
|
case VAR_FLOAT:
|
||||||
|
case VAR_FUNC:
|
||||||
EMSG(_("E701: Invalid type for len()"));
|
EMSG(_("E701: Invalid type for len()"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -16215,7 +16238,11 @@ static void f_type(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VAR_UNKNOWN: EMSG2(_(e_intern2), "f_type()"); n = 0; break;
|
case VAR_UNKNOWN: {
|
||||||
|
EMSG2(_(e_intern2), "f_type(UNKNOWN)");
|
||||||
|
n = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rettv->vval.v_number = n;
|
rettv->vval.v_number = n;
|
||||||
}
|
}
|
||||||
@@ -17529,7 +17556,7 @@ long get_tv_number_chk(typval_T *varp, int *denote)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
EMSG2(_(e_intern2), "get_tv_number()");
|
EMSG2(_(e_intern2), "get_tv_number(UNKNOWN)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (denote == NULL) {
|
if (denote == NULL) {
|
||||||
@@ -17638,7 +17665,7 @@ static char_u *get_tv_string_buf_chk(const typval_T *varp, char_u *buf)
|
|||||||
STRCPY(buf, encode_special_var_names[varp->vval.v_special]);
|
STRCPY(buf, encode_special_var_names[varp->vval.v_special]);
|
||||||
return buf;
|
return buf;
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
EMSG2(_(e_intern2), "get_tv_string_buf()");
|
EMSG(_("E908: using an invalid value as a String"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -18212,7 +18239,7 @@ void copy_tv(typval_T *from, typval_T *to)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
EMSG2(_(e_intern2), "copy_tv()");
|
EMSG2(_(e_intern2), "copy_tv(UNKNOWN)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18301,7 +18328,7 @@ int var_item_copy(const vimconv_T *const conv,
|
|||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
break;
|
break;
|
||||||
case VAR_UNKNOWN:
|
case VAR_UNKNOWN:
|
||||||
EMSG2(_(e_intern2), "var_item_copy()");
|
EMSG2(_(e_intern2), "var_item_copy(UNKNOWN)");
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
--recurse;
|
--recurse;
|
||||||
|
@@ -95,7 +95,7 @@ static int included_patches[] = {
|
|||||||
// 1270
|
// 1270
|
||||||
// 1269
|
// 1269
|
||||||
// 1268
|
// 1268
|
||||||
// 1267
|
1267,
|
||||||
// 1266
|
// 1266
|
||||||
// 1265
|
// 1265
|
||||||
// 1264
|
// 1264
|
||||||
|
@@ -147,9 +147,9 @@ describe('Special values', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('fails in index', function()
|
it('fails in index', function()
|
||||||
eq('Vim(echo):E15: Cannot index a special value', exc_exec('echo v:true[0]'))
|
eq('Vim(echo):E909: Cannot index a special variable', exc_exec('echo v:true[0]'))
|
||||||
eq('Vim(echo):E15: Cannot index a special value', exc_exec('echo v:false[0]'))
|
eq('Vim(echo):E909: Cannot index a special variable', exc_exec('echo v:false[0]'))
|
||||||
eq('Vim(echo):E15: Cannot index a special value', exc_exec('echo v:null[0]'))
|
eq('Vim(echo):E909: Cannot index a special variable', exc_exec('echo v:null[0]'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is accepted by assert_true and assert_false', function()
|
it('is accepted by assert_true and assert_false', function()
|
||||||
|
Reference in New Issue
Block a user