0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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.
This commit is contained in:
Bram Moolenaar 2020-02-29 17:38:12 +01:00
parent 57c339569e
commit dd58923c6b
7 changed files with 30 additions and 13 deletions

View File

@ -5560,7 +5560,7 @@ tv_get_number_chk(typval_T *varp, int *denote)
break; break;
case VAR_UNKNOWN: case VAR_UNKNOWN:
case VAR_VOID: case VAR_VOID:
internal_error("tv_get_number(UNKNOWN)"); internal_error_no_abort("tv_get_number(UNKNOWN)");
break; break;
} }
if (denote == NULL) // useful for values that must be unsigned if (denote == NULL) // useful for values that must be unsigned
@ -5614,7 +5614,7 @@ tv_get_float(typval_T *varp)
break; break;
case VAR_UNKNOWN: case VAR_UNKNOWN:
case VAR_VOID: case VAR_VOID:
internal_error("tv_get_float(UNKNOWN)"); internal_error_no_abort("tv_get_float(UNKNOWN)");
break; break;
} }
return 0; return 0;
@ -5886,7 +5886,7 @@ copy_tv(typval_T *from, typval_T *to)
break; break;
case VAR_UNKNOWN: case VAR_UNKNOWN:
case VAR_VOID: case VAR_VOID:
internal_error("copy_tv(UNKNOWN)"); internal_error_no_abort("copy_tv(UNKNOWN)");
break; break;
} }
} }
@ -5965,7 +5965,7 @@ item_copy(
break; break;
case VAR_UNKNOWN: case VAR_UNKNOWN:
case VAR_VOID: case VAR_VOID:
internal_error("item_copy(UNKNOWN)"); internal_error_no_abort("item_copy(UNKNOWN)");
ret = FAIL; ret = FAIL;
} }
--recurse; --recurse;

View File

@ -1890,10 +1890,7 @@ f_empty(typval_T *argvars, typval_T *rettv)
#endif #endif
case VAR_UNKNOWN: case VAR_UNKNOWN:
case VAR_VOID: case VAR_VOID:
// Let's not use internal_error() here, otherwise internal_error_no_abort("f_empty(UNKNOWN)");
// empty(test_unknown()) with ABORT_ON_INTERNAL_ERROR defined makes
// Vim abort.
semsg(_(e_intern2), "f_empty(UNKNOWN)");
n = TRUE; n = TRUE;
break; break;
} }
@ -8278,10 +8275,7 @@ f_type(typval_T *argvars, typval_T *rettv)
case VAR_BLOB: n = VAR_TYPE_BLOB; break; case VAR_BLOB: n = VAR_TYPE_BLOB; break;
case VAR_UNKNOWN: case VAR_UNKNOWN:
case VAR_VOID: case VAR_VOID:
// Let's not use internal_error() here, otherwise internal_error_no_abort("f_type(UNKNOWN)");
// empty(test_unknown()) with ABORT_ON_INTERNAL_ERROR defined
// makes Vim abort.
semsg(_(e_intern2), "f_type(UNKNOWN)");
n = -1; n = -1;
break; break;
} }

View File

@ -352,7 +352,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
#endif #endif
case VAR_UNKNOWN: case VAR_UNKNOWN:
case VAR_VOID: case VAR_VOID:
internal_error("json_encode_item()"); internal_error_no_abort("json_encode_item()");
return FAIL; return FAIL;
} }
return OK; return OK;

View File

@ -838,6 +838,16 @@ internal_error(char *where)
siemsg(_(e_intern2), 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. // emsg3() and emsgn() are in misc2.c to avoid warnings for the prototypes.
void void

View File

@ -12,6 +12,7 @@ void do_perror(char *msg);
int emsg(char *s); int emsg(char *s);
void iemsg(char *s); void iemsg(char *s);
void internal_error(char *where); void internal_error(char *where);
void internal_error_no_abort(char *where);
void emsg_invreg(int name); void emsg_invreg(int name);
void emsg_namelen(char *msg, char_u *name, int len); void emsg_namelen(char *msg, char_u *name, int len);
char *msg_trunc_attr(char *s, int force, int attr); char *msg_trunc_attr(char *s, int force, int attr);

View File

@ -63,6 +63,16 @@ func Test_empty()
call assert_fails("call empty(test_unknown())", 'E685:') call assert_fails("call empty(test_unknown())", 'E685:')
endfunc 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() func Test_len()
call assert_equal(1, len(0)) call assert_equal(1, len(0))
call assert_equal(2, len(12)) call assert_equal(2, len(12))

View File

@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
334,
/**/ /**/
333, 333,
/**/ /**/