# HG changeset patch # User Bram Moolenaar # Date 1582994704 -3600 # Node ID b38d73f36467af5c26cb920cb60180f98b238c87 # Parent 45b9e23467dabcd735411c879bda988278a78522 patch 8.2.0334: abort called when using test_void() Commit: https://github.com/vim/vim/commit/dd58923c6bcb026de7134d9874e69e0a2b01682d Author: Bram Moolenaar 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. diff --git a/src/eval.c b/src/eval.c --- 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; diff --git a/src/evalfunc.c b/src/evalfunc.c --- 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; } diff --git a/src/json.c b/src/json.c --- 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; diff --git a/src/message.c b/src/message.c --- 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 diff --git a/src/proto/message.pro b/src/proto/message.pro --- 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); diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim --- 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)) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 334, +/**/ 333, /**/ 332,