Mercurial > vim
changeset 19554:b38d73f36467 v8.2.0334
patch 8.2.0334: abort called when using test_void()
Commit: https://github.com/vim/vim/commit/dd58923c6bcb026de7134d9874e69e0a2b01682d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 29 17:38:12 2020 +0100
patch 8.2.0334: abort called when using test_void()
Problem: Abort called when using test_void(). (Dominique Pelle)
Solution: Only give an error, don't abort.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 29 Feb 2020 17:45:04 +0100 |
parents | 45b9e23467da |
children | aae35642cc05 |
files | src/eval.c src/evalfunc.c src/json.c src/message.c src/proto/message.pro src/testdir/test_functions.vim src/version.c |
diffstat | 7 files changed, 30 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -5560,7 +5560,7 @@ tv_get_number_chk(typval_T *varp, int *d break; case VAR_UNKNOWN: case VAR_VOID: - internal_error("tv_get_number(UNKNOWN)"); + internal_error_no_abort("tv_get_number(UNKNOWN)"); break; } if (denote == NULL) // useful for values that must be unsigned @@ -5614,7 +5614,7 @@ tv_get_float(typval_T *varp) break; case VAR_UNKNOWN: case VAR_VOID: - internal_error("tv_get_float(UNKNOWN)"); + internal_error_no_abort("tv_get_float(UNKNOWN)"); break; } return 0; @@ -5886,7 +5886,7 @@ copy_tv(typval_T *from, typval_T *to) break; case VAR_UNKNOWN: case VAR_VOID: - internal_error("copy_tv(UNKNOWN)"); + internal_error_no_abort("copy_tv(UNKNOWN)"); break; } } @@ -5965,7 +5965,7 @@ item_copy( break; case VAR_UNKNOWN: case VAR_VOID: - internal_error("item_copy(UNKNOWN)"); + internal_error_no_abort("item_copy(UNKNOWN)"); ret = FAIL; } --recurse;
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1890,10 +1890,7 @@ f_empty(typval_T *argvars, typval_T *ret #endif case VAR_UNKNOWN: case VAR_VOID: - // Let's not use internal_error() here, otherwise - // empty(test_unknown()) with ABORT_ON_INTERNAL_ERROR defined makes - // Vim abort. - semsg(_(e_intern2), "f_empty(UNKNOWN)"); + internal_error_no_abort("f_empty(UNKNOWN)"); n = TRUE; break; } @@ -8278,10 +8275,7 @@ f_type(typval_T *argvars, typval_T *rett case VAR_BLOB: n = VAR_TYPE_BLOB; break; case VAR_UNKNOWN: case VAR_VOID: - // Let's not use internal_error() here, otherwise - // empty(test_unknown()) with ABORT_ON_INTERNAL_ERROR defined - // makes Vim abort. - semsg(_(e_intern2), "f_type(UNKNOWN)"); + internal_error_no_abort("f_type(UNKNOWN)"); n = -1; break; }
--- a/src/json.c +++ b/src/json.c @@ -352,7 +352,7 @@ json_encode_item(garray_T *gap, typval_T #endif case VAR_UNKNOWN: case VAR_VOID: - internal_error("json_encode_item()"); + internal_error_no_abort("json_encode_item()"); return FAIL; } return OK;
--- a/src/message.c +++ b/src/message.c @@ -838,6 +838,16 @@ internal_error(char *where) siemsg(_(e_intern2), where); } +/* + * Like internal_error() but do not call abort(), to avoid tests using + * test_unknown() and test_void() causing Vim to exit. + */ + void +internal_error_no_abort(char *where) +{ + semsg(_(e_intern2), where); +} + // emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes. void
--- a/src/proto/message.pro +++ b/src/proto/message.pro @@ -12,6 +12,7 @@ void do_perror(char *msg); int emsg(char *s); void iemsg(char *s); void internal_error(char *where); +void internal_error_no_abort(char *where); void emsg_invreg(int name); void emsg_namelen(char *msg, char_u *name, int len); char *msg_trunc_attr(char *s, int force, int attr);
--- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -63,6 +63,16 @@ func Test_empty() call assert_fails("call empty(test_unknown())", 'E685:') endfunc +func Test_test_void() + call assert_fails('echo 1 == test_void()', 'E685:') + if has('float') + call assert_fails('echo 1.0 == test_void()', 'E685:') + endif + call assert_fails('let x = json_encode(test_void())', 'E685:') + call assert_fails('let x = copy(test_void())', 'E685:') + call assert_fails('let x = copy([test_void()])', 'E685:') +endfunc + func Test_len() call assert_equal(1, len(0)) call assert_equal(2, len(12))