diff options
-rw-r--r-- | runtime/doc/eval.txt | 9 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 4 | ||||
-rw-r--r-- | src/nvim/api/private/helpers.c | 3 | ||||
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | src/nvim/eval.h | 1 | ||||
-rw-r--r-- | src/nvim/eval/encode.c | 17 | ||||
-rw-r--r-- | src/nvim/eval_defs.h | 3 | ||||
-rw-r--r-- | test/functional/eval/msgpack_functions_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/eval/special_vars_spec.lua | 32 | ||||
-rw-r--r-- | test/functional/eval/string_spec.lua | 1 |
10 files changed, 8 insertions, 73 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index ee8ede2b91..f085dd2972 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1571,13 +1571,6 @@ v:null Special value used to put "null" in JSON and NIL in msgpack. 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* v:oldfiles List of file names that is loaded from the |shada| file on startup. These are the files that Vim remembers marks for. @@ -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. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index ddb1fd3b8f..2d03b4ff45 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -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: diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index a8082655fd..9082dfd759 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -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; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index dc7737e4ce..4919cc2ce8 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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; } diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 40111abf8d..c2b67cd12e 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -124,7 +124,6 @@ typedef enum { VV_FALSE, VV_TRUE, VV_NULL, - VV_NONE, } VimVarIndex; /// All recognized msgpack types diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 0fc975ed42..1550a61f7f 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -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 diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h index bcd9e80f9a..3c119c44e1 100644 --- a/src/nvim/eval_defs.h +++ b/src/nvim/eval_defs.h @@ -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; diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua index 3d539d855d..a602bad86f 100644 --- a/test/functional/eval/msgpack_functions_spec.lua +++ b/test/functional/eval/msgpack_functions_spec.lua @@ -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 diff --git a/test/functional/eval/special_vars_spec.lua b/test/functional/eval/special_vars_spec.lua index c7df847946..b5c65d23d9 100644 --- a/test/functional/eval/special_vars_spec.lua +++ b/test/functional/eval/special_vars_spec.lua @@ -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) diff --git a/test/functional/eval/string_spec.lua b/test/functional/eval/string_spec.lua index fe79708910..0c4ff87231 100644 --- a/test/functional/eval/string_spec.lua +++ b/test/functional/eval/string_spec.lua @@ -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) |