diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-29 17:38:12 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-29 17:38:12 +0100 |
commit | dd58923c6bcb026de7134d9874e69e0a2b01682d (patch) | |
tree | 96e5bb7145241ace4d7f217640cecb039d2b3d5d | |
parent | 57c339569e96725e24e79944bf99f70c50afb5b1 (diff) | |
download | vim-git-dd58923c6bcb026de7134d9874e69e0a2b01682d.tar.gz |
patch 8.2.0334: abort called when using test_void()v8.2.0334
Problem: Abort called when using test_void(). (Dominique Pelle)
Solution: Only give an error, don't abort.
-rw-r--r-- | src/eval.c | 8 | ||||
-rw-r--r-- | src/evalfunc.c | 10 | ||||
-rw-r--r-- | src/json.c | 2 | ||||
-rw-r--r-- | src/message.c | 10 | ||||
-rw-r--r-- | src/proto/message.pro | 1 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 10 | ||||
-rw-r--r-- | src/version.c | 2 |
7 files changed, 30 insertions, 13 deletions
diff --git a/src/eval.c b/src/eval.c index dcaf2f02c..c81ece149 100644 --- a/src/eval.c +++ b/src/eval.c @@ -5560,7 +5560,7 @@ tv_get_number_chk(typval_T *varp, int *denote) 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 index 3fce946bf..39e347ad2 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1890,10 +1890,7 @@ f_empty(typval_T *argvars, typval_T *rettv) #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 *rettv) 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 index d5e5782c5..f4a03e61a 100644 --- a/src/json.c +++ b/src/json.c @@ -352,7 +352,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options) #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 index c2855fb34..cb1a773ce 100644 --- 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 index 5c9ca6cb1..16c335484 100644 --- 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 index 6f3b81a30..ef4180a77 100644 --- 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 index a8289633b..4dc9642a5 100644 --- 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, |