mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
eval: Remove v:none
To get v:none back just rever this commit. This will not make json*() functions compatible with Vim though.
This commit is contained in:
parent
a3b87fc19b
commit
6167ce6df2
@ -1569,13 +1569,6 @@ v:null Special value used to put "null" in JSON and NIL in msgpack.
|
||||
See |jsonencode()|. This value is converted to "null" when
|
||||
used as a String (e.g. in |expr5| with string concatenation
|
||||
operator) and to zero when used as a Number (e.g. in |expr5|
|
||||
or |expr7| when used with numeric operators).
|
||||
|
||||
*v:none* *none-variable*
|
||||
v:none Special value used to put an empty item in JSON. See
|
||||
|jsonencode()|. This value is converted to "none" when used
|
||||
as a String (e.g. in |expr5| with string concatenation
|
||||
operator) and to zero when used as a Number (e.g. in |expr5|
|
||||
or |expr7| when used with numeric operators).
|
||||
|
||||
*v:oldfiles* *oldfiles-variable*
|
||||
@ -4876,7 +4869,7 @@ msgpackdump({list}) {Nvim} *msgpackdump()*
|
||||
messagepack).
|
||||
|
||||
Limitations: *E951* *E952* *E953*
|
||||
1. |Funcref|s and |v:none| cannot be dumped.
|
||||
1. |Funcref|s cannot be dumped.
|
||||
2. Containers that reference themselves cannot be dumped.
|
||||
3. Dictionary keys are always dumped as STR strings.
|
||||
4. Other strings are always dumped as BIN strings.
|
||||
|
@ -106,6 +106,10 @@ are always available and may be used simultaneously in separate plugins. The
|
||||
|jsonencode()| behaviour slightly changed: now |msgpack-special-dict| values
|
||||
are accepted.
|
||||
|
||||
*v:none* variable is absent. In Vim it represents “no value” in non-JSON
|
||||
strings like "{"a": }" parsed as "{'a': v:none}". See |jsondecode()| and
|
||||
|jsonencode()| incompatibilities above.
|
||||
|
||||
Viminfo text files were replaced with binary (messagepack) ShaDa files.
|
||||
Additional differences:
|
||||
|
||||
|
@ -659,8 +659,7 @@ static Object vim_to_object_rec(typval_T *obj, PMap(ptr_t) *lookup)
|
||||
rv.data.boolean = (obj->vval.v_special == kSpecialVarTrue);
|
||||
break;
|
||||
}
|
||||
case kSpecialVarNull:
|
||||
case kSpecialVarNone: {
|
||||
case kSpecialVarNull: {
|
||||
rv.type = kObjectTypeNil;
|
||||
break;
|
||||
}
|
||||
|
@ -368,7 +368,6 @@ static struct vimvar {
|
||||
{ VV_NAME("false", VAR_SPECIAL), VV_RO },
|
||||
{ VV_NAME("true", VAR_SPECIAL), VV_RO },
|
||||
{ VV_NAME("null", VAR_SPECIAL), VV_RO },
|
||||
{ VV_NAME("none", VAR_SPECIAL), VV_RO },
|
||||
};
|
||||
|
||||
/* shorthand */
|
||||
@ -512,7 +511,6 @@ void eval_init(void)
|
||||
|
||||
set_vim_var_special(VV_FALSE, kSpecialVarFalse);
|
||||
set_vim_var_special(VV_TRUE, kSpecialVarTrue);
|
||||
set_vim_var_special(VV_NONE, kSpecialVarNone);
|
||||
set_vim_var_special(VV_NULL, kSpecialVarNull);
|
||||
|
||||
set_reg_var(0); // default for v:register is not 0 but '"'
|
||||
@ -16204,7 +16202,6 @@ static void f_type(typval_T *argvars, typval_T *rettv)
|
||||
n = 6;
|
||||
break;
|
||||
}
|
||||
case kSpecialVarNone:
|
||||
case kSpecialVarNull: {
|
||||
n = 7;
|
||||
break;
|
||||
@ -17520,7 +17517,6 @@ long get_tv_number_chk(typval_T *varp, int *denote)
|
||||
return 1;
|
||||
}
|
||||
case kSpecialVarFalse:
|
||||
case kSpecialVarNone:
|
||||
case kSpecialVarNull: {
|
||||
return 0;
|
||||
}
|
||||
|
@ -124,7 +124,6 @@ typedef enum {
|
||||
VV_FALSE,
|
||||
VV_TRUE,
|
||||
VV_NULL,
|
||||
VV_NONE,
|
||||
} VimVarIndex;
|
||||
|
||||
/// All recognized msgpack types
|
||||
|
@ -55,7 +55,6 @@ typedef kvec_t(MPConvStackVal) MPConvStack;
|
||||
|
||||
const char *const encode_special_var_names[] = {
|
||||
[kSpecialVarNull] = "null",
|
||||
[kSpecialVarNone] = "none",
|
||||
[kSpecialVarTrue] = "true",
|
||||
[kSpecialVarFalse] = "false",
|
||||
};
|
||||
@ -358,10 +357,6 @@ static int name##_convert_one_value(firstargtype firstargname, \
|
||||
CONV_BOOL(tv->vval.v_special == kSpecialVarTrue); \
|
||||
break; \
|
||||
} \
|
||||
case kSpecialVarNone: { \
|
||||
CONV_NONE_VAL(); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
@ -726,9 +721,6 @@ encode_vim_to_##name##_error_ret: \
|
||||
#define CONV_BOOL(num) \
|
||||
ga_concat(gap, ((num)? "v:true": "v:false"))
|
||||
|
||||
#define CONV_NONE_VAL() \
|
||||
ga_concat(gap, "v:none")
|
||||
|
||||
#define CONV_UNSIGNED_NUMBER(num)
|
||||
|
||||
#define CONV_DICT_START(len) \
|
||||
@ -1074,9 +1066,6 @@ static inline bool check_json_key(const typval_T *const tv)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#undef CONV_NONE_VAL
|
||||
#define CONV_NONE_VAL()
|
||||
|
||||
DEFINE_VIML_CONV_FUNCTIONS(static, json, garray_T *const, gap)
|
||||
|
||||
#undef CONV_STRING
|
||||
@ -1090,7 +1079,6 @@ DEFINE_VIML_CONV_FUNCTIONS(static, json, garray_T *const, gap)
|
||||
#undef CONV_EMPTY_DICT
|
||||
#undef CONV_NIL
|
||||
#undef CONV_BOOL
|
||||
#undef CONV_NONE_VAL
|
||||
#undef CONV_UNSIGNED_NUMBER
|
||||
#undef CONV_DICT_START
|
||||
#undef CONV_DICT_END
|
||||
@ -1226,10 +1214,6 @@ char *encode_tv2json(typval_T *tv, size_t *len)
|
||||
#define CONV_NIL() \
|
||||
msgpack_pack_nil(packer)
|
||||
|
||||
#define CONV_NONE_VAL() \
|
||||
return conv_error(_("E953: Attempt to convert v:none in %s, %s"), \
|
||||
mpstack, objname)
|
||||
|
||||
#define CONV_BOOL(num) \
|
||||
do { \
|
||||
if ((num)) { \
|
||||
@ -1277,7 +1261,6 @@ DEFINE_VIML_CONV_FUNCTIONS(, msgpack, msgpack_packer *const, packer)
|
||||
#undef CONV_EMPTY_DICT
|
||||
#undef CONV_NIL
|
||||
#undef CONV_BOOL
|
||||
#undef CONV_NONE_VAL
|
||||
#undef CONV_UNSIGNED_NUMBER
|
||||
#undef CONV_DICT_START
|
||||
#undef CONV_DICT_END
|
||||
|
@ -20,7 +20,6 @@ typedef struct dictvar_S dict_T;
|
||||
typedef enum {
|
||||
kSpecialVarFalse, ///< v:false
|
||||
kSpecialVarTrue, ///< v:true
|
||||
kSpecialVarNone, ///< v:none
|
||||
kSpecialVarNull, ///< v:null
|
||||
} SpecialVarValue;
|
||||
|
||||
@ -40,7 +39,7 @@ typedef enum {
|
||||
VAR_LIST, ///< List, .v_list is used.
|
||||
VAR_DICT, ///< Dictionary, .v_dict is used.
|
||||
VAR_FLOAT, ///< Floating-point value, .v_float is used.
|
||||
VAR_SPECIAL, ///< Special value (true, false, null, none), .v_special
|
||||
VAR_SPECIAL, ///< Special value (true, false, null), .v_special
|
||||
///< is used.
|
||||
} VarType;
|
||||
|
||||
|
@ -645,11 +645,6 @@ describe('msgpackdump() function', function()
|
||||
exc_exec('call msgpackdump([todump])'))
|
||||
end)
|
||||
|
||||
it('fails to dump v:none', function()
|
||||
eq('Vim(call):E953: Attempt to convert v:none in msgpackdump() argument, index 0, itself',
|
||||
exc_exec('call msgpackdump([v:none])'))
|
||||
end)
|
||||
|
||||
it('fails when called with no arguments', function()
|
||||
eq('Vim(call):E119: Not enough arguments for function: msgpackdump',
|
||||
exc_exec('call msgpackdump()'))
|
||||
@ -686,7 +681,7 @@ describe('msgpackdump() function', function()
|
||||
end)
|
||||
|
||||
it('fails to dump special value', function()
|
||||
for _, val in ipairs({'v:true', 'v:false', 'v:null', 'v:none'}) do
|
||||
for _, val in ipairs({'v:true', 'v:false', 'v:null'}) do
|
||||
eq('Vim(call):E686: Argument of msgpackdump() must be a List',
|
||||
exc_exec('call msgpackdump(' .. val .. ')'))
|
||||
end
|
||||
|
@ -28,21 +28,15 @@ describe('Special values', function()
|
||||
eq(0, funcs.empty(true))
|
||||
eq(1, funcs.empty(false))
|
||||
eq(1, eval('empty(v:null)'))
|
||||
eq(1, eval('empty(v:none)'))
|
||||
end)
|
||||
|
||||
it('can be stringified and eval’ed back', function()
|
||||
eq(true, funcs.eval(funcs.string(true)))
|
||||
eq(false, funcs.eval(funcs.string(false)))
|
||||
eq(nil, eval('eval(string(v:null))'))
|
||||
eq(1, eval('eval(string(v:none)) is# v:none'))
|
||||
end)
|
||||
|
||||
it('work with is/isnot properly', function()
|
||||
eq(1, eval('v:none is v:none'))
|
||||
eq(0, eval('v:none is v:null'))
|
||||
eq(0, eval('v:none is v:true'))
|
||||
eq(0, eval('v:none is v:false'))
|
||||
eq(1, eval('v:null is v:null'))
|
||||
eq(0, eval('v:null is v:true'))
|
||||
eq(0, eval('v:null is v:false'))
|
||||
@ -50,35 +44,26 @@ describe('Special values', function()
|
||||
eq(0, eval('v:true is v:false'))
|
||||
eq(1, eval('v:false is v:false'))
|
||||
|
||||
eq(0, eval('v:none is 0'))
|
||||
eq(0, eval('v:null is 0'))
|
||||
eq(0, eval('v:true is 0'))
|
||||
eq(0, eval('v:false is 0'))
|
||||
|
||||
eq(0, eval('v:none is 1'))
|
||||
eq(0, eval('v:null is 1'))
|
||||
eq(0, eval('v:true is 1'))
|
||||
eq(0, eval('v:false is 1'))
|
||||
|
||||
eq(0, eval('v:none is ""'))
|
||||
eq(0, eval('v:null is ""'))
|
||||
eq(0, eval('v:true is ""'))
|
||||
eq(0, eval('v:false is ""'))
|
||||
|
||||
eq(0, eval('v:none is "none"'))
|
||||
eq(0, eval('v:null is "null"'))
|
||||
eq(0, eval('v:true is "true"'))
|
||||
eq(0, eval('v:false is "false"'))
|
||||
|
||||
eq(0, eval('v:none is []'))
|
||||
eq(0, eval('v:null is []'))
|
||||
eq(0, eval('v:true is []'))
|
||||
eq(0, eval('v:false is []'))
|
||||
|
||||
eq(0, eval('v:none isnot v:none'))
|
||||
eq(1, eval('v:none isnot v:null'))
|
||||
eq(1, eval('v:none isnot v:true'))
|
||||
eq(1, eval('v:none isnot v:false'))
|
||||
eq(0, eval('v:null isnot v:null'))
|
||||
eq(1, eval('v:null isnot v:true'))
|
||||
eq(1, eval('v:null isnot v:false'))
|
||||
@ -86,27 +71,22 @@ describe('Special values', function()
|
||||
eq(1, eval('v:true isnot v:false'))
|
||||
eq(0, eval('v:false isnot v:false'))
|
||||
|
||||
eq(1, eval('v:none isnot 0'))
|
||||
eq(1, eval('v:null isnot 0'))
|
||||
eq(1, eval('v:true isnot 0'))
|
||||
eq(1, eval('v:false isnot 0'))
|
||||
|
||||
eq(1, eval('v:none isnot 1'))
|
||||
eq(1, eval('v:null isnot 1'))
|
||||
eq(1, eval('v:true isnot 1'))
|
||||
eq(1, eval('v:false isnot 1'))
|
||||
|
||||
eq(1, eval('v:none isnot ""'))
|
||||
eq(1, eval('v:null isnot ""'))
|
||||
eq(1, eval('v:true isnot ""'))
|
||||
eq(1, eval('v:false isnot ""'))
|
||||
|
||||
eq(1, eval('v:none isnot "none"'))
|
||||
eq(1, eval('v:null isnot "null"'))
|
||||
eq(1, eval('v:true isnot "true"'))
|
||||
eq(1, eval('v:false isnot "false"'))
|
||||
|
||||
eq(1, eval('v:none isnot []'))
|
||||
eq(1, eval('v:null isnot []'))
|
||||
eq(1, eval('v:true isnot []'))
|
||||
eq(1, eval('v:false isnot []'))
|
||||
@ -114,17 +94,14 @@ describe('Special values', function()
|
||||
|
||||
it('work with +/-/* properly', function()
|
||||
eq(1, eval('0 + v:true'))
|
||||
eq(0, eval('0 + v:none'))
|
||||
eq(0, eval('0 + v:null'))
|
||||
eq(0, eval('0 + v:false'))
|
||||
|
||||
eq(-1, eval('0 - v:true'))
|
||||
eq( 0, eval('0 - v:none'))
|
||||
eq( 0, eval('0 - v:null'))
|
||||
eq( 0, eval('0 - v:false'))
|
||||
|
||||
eq(1, eval('1 * v:true'))
|
||||
eq(0, eval('1 * v:none'))
|
||||
eq(0, eval('1 * v:null'))
|
||||
eq(0, eval('1 * v:false'))
|
||||
end)
|
||||
@ -132,28 +109,23 @@ describe('Special values', function()
|
||||
it('does not work with +=/-=/.=', function()
|
||||
meths.set_var('true', true)
|
||||
meths.set_var('false', false)
|
||||
execute('let none = v:none')
|
||||
execute('let null = v:null')
|
||||
|
||||
eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let true += 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let false += 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let none += 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let null += 1'))
|
||||
|
||||
eq('Vim(let):E734: Wrong variable type for -=', exc_exec('let true -= 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for -=', exc_exec('let false -= 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for -=', exc_exec('let none -= 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for -=', exc_exec('let null -= 1'))
|
||||
|
||||
eq('Vim(let):E734: Wrong variable type for .=', exc_exec('let true .= 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for .=', exc_exec('let false .= 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for .=', exc_exec('let none .= 1'))
|
||||
eq('Vim(let):E734: Wrong variable type for .=', exc_exec('let null .= 1'))
|
||||
end)
|
||||
|
||||
it('work with . (concat) properly', function()
|
||||
eq("true", eval('"" . v:true'))
|
||||
eq("none", eval('"" . v:none'))
|
||||
eq("null", eval('"" . v:null'))
|
||||
eq("false", eval('"" . v:false'))
|
||||
end)
|
||||
@ -162,25 +134,21 @@ describe('Special values', function()
|
||||
eq(6, funcs.type(true))
|
||||
eq(6, funcs.type(false))
|
||||
eq(7, eval('type(v:null)'))
|
||||
eq(7, eval('type(v:none)'))
|
||||
end)
|
||||
|
||||
it('work with copy() and deepcopy()', function()
|
||||
eq(true, funcs.deepcopy(true))
|
||||
eq(false, funcs.deepcopy(false))
|
||||
eq(nil, eval('deepcopy(v:null)'))
|
||||
eq(nil, eval('deepcopy(v:none)'))
|
||||
|
||||
eq(true, funcs.copy(true))
|
||||
eq(false, funcs.copy(false))
|
||||
eq(nil, eval('copy(v:null)'))
|
||||
eq(nil, eval('copy(v:none)'))
|
||||
end)
|
||||
|
||||
it('fails in index', function()
|
||||
eq('Vim(echo):E15: Cannot index a special value', exc_exec('echo v:true[0]'))
|
||||
eq('Vim(echo):E15: Cannot index a special value', exc_exec('echo v:false[0]'))
|
||||
eq('Vim(echo):E15: Cannot index a special value', exc_exec('echo v:none[0]'))
|
||||
eq('Vim(echo):E15: Cannot index a special value', exc_exec('echo v:null[0]'))
|
||||
end)
|
||||
end)
|
||||
|
@ -31,7 +31,6 @@ describe('string() function', function()
|
||||
it('dumps special v: values', function()
|
||||
eq('v:true', eval('string(v:true)'))
|
||||
eq('v:false', eval('string(v:false)'))
|
||||
eq('v:none', eval('string(v:none)'))
|
||||
eq('v:null', eval('string(v:null)'))
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user