diff options
-rw-r--r-- | runtime/doc/eval.txt | 4 | ||||
-rw-r--r-- | src/nvim/eval.c | 27 | ||||
-rw-r--r-- | test/functional/eval/msgpack_functions_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/plugin/msgpack_spec.lua | 24 |
4 files changed, 3 insertions, 54 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index f70968de01..49afa15601 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4719,10 +4719,6 @@ msgpackdump({list}) {Nvim} *msgpackdump()* 4. Other strings are always dumped as BIN strings. 5. Points 3. and 4. do not apply to |msgpack-special-dict|s. - Note: error messages may use |msgpack#string()| function for - showing where error occurred. In case it is not - available it falls back to |string()|. - msgpackparse({list}) {Nvim} *msgpackparse()* Convert a |readfile()|-style list to a list of VimL objects. Example: > diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 5a8fe4076e..57d7002739 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12744,32 +12744,9 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, ga_concat(&msg_ga, IObuff); } else { typval_T key_tv = li->li_tv.vval.v_list->lv_first->li_tv; - trylevel++; - typval_T rettv; - int doesrange; - char *key; - bool free_key = false; - if (call_func((char_u *) "msgpack#string", - sizeof("msgpack#string") - 1, - &rettv, 1, &key_tv, 0L, 0L, &doesrange, true, - NULL) == FAIL - || ((key = (char *) get_tv_string(&rettv)) == NULL) - || did_throw - || (msg_list != NULL && *msg_list != NULL)) { - key = tv2string(&key_tv, NULL); - free_key = true; - } - did_emsg = false; - discard_current_exception(); - if (msg_list != NULL && *msg_list != NULL) { - free_global_msglist(); - } - trylevel--; + char *const key = echo_string(&key_tv, NULL); vim_snprintf((char *) IObuff, IOSIZE, key_pair_msg, key, idx); - clear_tv(&rettv); - if (free_key) { - xfree(key); - } + xfree(key); ga_concat(&msg_ga, IObuff); } break; diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua index 4f2533f49d..41b0faf76c 100644 --- a/test/functional/eval/msgpack_functions_spec.lua +++ b/test/functional/eval/msgpack_functions_spec.lua @@ -601,7 +601,7 @@ describe('msgpackdump() function', function() it('fails to dump a recursive (key) map in a special dict, _VAL reference', function() execute('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[[], []]]}') execute('call add(todump._VAL[0][0], todump._VAL)') - eq('Vim(call):E952: Unable to dump msgpackdump() argument, index 0: container references itself in key [[[{E724@0}, []]]] at index 0 from special map, index 0', + eq('Vim(call):E952: Unable to dump msgpackdump() argument, index 0: container references itself in key [[[[...@0], []]]] at index 0 from special map, index 0', exc_exec('call msgpackdump([todump])')) end) diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua index 9cbfacd936..18ff0f5156 100644 --- a/test/functional/plugin/msgpack_spec.lua +++ b/test/functional/plugin/msgpack_spec.lua @@ -697,27 +697,3 @@ describe('In autoload/msgpack.vim', function() end) end) end) - -describe('msgpackdump() function', function() - before_each(reset) - - it('uses msgpack#string for dumping fref error messages for special map keys', function() - nvim_command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[{"_TYPE": v:msgpack_types.string, "_VAL": ["abc"]}, [function("tr")]]]}') - eq('Vim(call):E951: Error while dumping msgpackdump() argument, index 0, key ="abc" at index 0 from special map, index 0: attempt to dump function reference', - exc_exec('call msgpackdump([todump])')) - end) - - it('falls back to using string() in case of error (fref)', function() - nvim_command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[[function("tr")], []]]}') - nvim_command('call add(todump._VAL[0][0], todump._VAL[0][0])') - eq('Vim(call):E951: Error while dumping msgpackdump() argument, index 0, key [function(\'tr\'), {E724@0}] at index 0 from special map, index 0: attempt to dump function reference', - exc_exec('call msgpackdump([todump])')) - end) - - it('falls back to using string() in case of error (recurse)', function() - nvim_command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[[], []]]}') - nvim_command('call add(todump._VAL[0][0], todump._VAL[0][0])') - eq('Vim(call):E952: Unable to dump msgpackdump() argument, index 0: container references itself in key [{E724@0}] at index 0 from special map, index 0', - exc_exec('call msgpackdump([todump])')) - end) -end) |